public static void initBugly(Context context) {// 1. Pre-build initialization parameters. These initialization parameters are required.String appID = "a278f01047"; // [Required] Product APPID.String appKey = "1e5ab6b3-b6fa-4f9b-a3c2-743d31dffe86"; // [Required] Product APPKEY.BuglyBuilder builder = new BuglyBuilder(appID, appKey);// 2. [Required] Configure the domain for reporting. Because Terminal Performance Monitoring Pro (RUM Pro) and Bugly use the same SDK, the domain for reporting is used to distinguish them.buglyBuilder.setServerHostType(BuglyBuilder.ServerHostTypeBuglyCloud);// 3. Basic initialization parameters. We recommend that you configure these initialization parameters.builder.uniqueId = "unique_id"; // [Recommended] Configure the device ID, which must be unique. If this is not configured, RUM Pro will generate a unique ID. This affects the statistics of device exception rates and connected devices. It is recommended to store and reuse it via SharedPreferences (SP).builder.userId = "user_id"; // [Recommended] Configure the user ID, which affects the statistics of user exception rates. It is recommended to store and reuse it via SP. Multiple settings within the same process lifecycle are not supported.builder.deviceModel = Build.MODEL; // [Recommended] Configure the device type. After the device model is configured, RUM Pro SDK no longer reads the system's device model.builder.appVersion = "1.0.0"; // [Recommended] Configure the app version number. If this is not configured, the value is read from packageManager. It is recommended to configure this manually according to the application's specifications. The value must be consistent with the application version parameter used for uploading the symbol table.builder.buildNumber = "builderNum"; // [Recommended] Configure the app build number. This is used for Java stack trace deobfuscation and must be consistent with the build number parameter used for uploading the symbol table.builder.appVersionType = BuglyAppVersionMode.Debug; // [Recommended] Configure the version type.// 4. Additional initialization parameters. Configure these initialization parameters as needed.builder.appChannel = "appChannel"; // Configure the app channel.builder.logLevel = BuglyLogLevel.LEVEL_DEBUG; // Configure the log printing level. Levels can be obtained from Bugly LogLevel.builder.enableAllThreadStackCrash = true; // Configure whether to capture all thread stacks on a crash. This is enabled by default.builder.enableAllThreadStackAnr = true; // Configure whether to capture all thread stacks on an Application Not Responding (ANR) error. This is enabled by default.builder.enableCrashProtect = true; // Configure whether to enable crash protection mode during performance monitoring. This is enabled by default.builder.debugMode = false; // Configure the debug mode, which can be enabled during the debugging phase.builder.initAppState = BuglyBuilder.APP_STATE_FOREGROUND; // Supported since version 4.4.3.7. This parameter is optional and can be used to specify the foreground and background state of the application during Bugly SDK initialization. If this is not specified, the SDK will determine the application's foreground and background state during initialization via getRunningAppProcesses. If this is specified, the SDK will use the assigned state without calling getRunningAppProcesses.// 5. Configure the callback methods. Configure the initialization parameters as needed.builder.setCrashHandleListener(crashHandleListener); // Configure the crash handling callback. For details, see the callback API.builder.setUploadHandleListener(uploadhandleListener); // Configure the crash reporting callback. For details, see the callback API.// 6. Initialization. This must be called.Bugly.init(context, builder);}
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback