Source code get to Github:https://github.com/drjia/androidlogcollector
has been made into the form of the SDK, the source code has been published, the source code can not understand the Google itself.
If you want to customize the SDK to suit your app, fork yourself.
Androidlogcollectorandroid app crash Log Collection SDK 1.0
Dr. Jia
Crash Log Collection method:
1.LogCollector is a Lib package that is imported into project that needs to join the crash Log SDK.
2. After you import lib, add the permissions in your project's Androidmanifest.xml file:
<uses-permission android:name=" Android.permission.READ_PHONE_STATE "/> <use S-permission android:name= "Android.permission.INTERNET"/> <uses-permission android:name= "android.permission . Write_external_storage "/> <uses-permission android:name=" Android.permission.ACCESS_NETWORK_STATE "/> <uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/>
3. Rewrite your application in your project and add in OnCreate
LogCollector.init(getApplicationContext(), UPLOAD_URL, params);
PS: Rewrite your own application remember in the manifest note booklet
Number of references:
1.Context
2.String upload_url, upload address URL, support HTTP and HTTPS mode, POST method.
3.HttpParameters params, the class of its own definition, used for post upload other parameters.
Description
After a crash, the log is saved under the/data/data/{your Package name}/files/folder
Log has only one file, multiple data logs are saved
Log file Upload success will be deleted on their own initiative, upload is not successful is not deleted
The log format can be modified in the source code according to your own needs
HTTP post-transmitted data can also be changed by itself
Reference code:
public class MyApplication extends application {//post method, upload logfile Url,replace your site. Support HTT P or HTTPS private static final String Upload_url = "http://xxxxxxxx"; @Override public void OnCreate () {super.oncreate (); Upload logfile, post params. Httpparameters params = new httpparameters (); Params.add ("Key1", "value1"); Params.add ("Key2", "value2"); Params.add ("Key3", "value3"); ......//replace your key and value; Boolean isdebug = true; Set debug mode, you can see the debug log, and also you can get the logfile in SDcard; Logcollector.setdebugmode (Isdebug); Logcollector.init (Getapplicationcontext (), upload_url, params);//params can be null}}
Upload Log method:
You need to run init in application first,
Then add code such as the following in whatever location:
LogCollector.upload(boolean isWifiOnly);
Number of references:
1.boolean iswifionly; True means that only the WiFi case is sent, false means that the network is sent (including traffic and WiFi)
You will be able to trigger at the right time in the service,activity and so on, no card interface will affect performance.
Reference code:
private void uploadLogFile(){ boolean isWifiOnly = true;//only wifi mode can upload LogCollector.upload(isWifiOnly);//upload at the right time }
Debugging:
Called Prior to Init
LogCollector.setDebugMode(boolean isDebug);
Description
1. You can see the log information of the stack after you turn on debugging
2. Ability to view saved crash log logs under the Android/data/{your Package name}/log/folder under the SD card at the same time
The log under this folder will not be deleted by itself, please clear it in time, avoid taking up space
Android app crash log collection and upload