Java Code Examples for com.tencent.bugly.crashreport.CrashReport#initCrashReport()

The following examples show how to use com.tencent.bugly.crashreport.CrashReport#initCrashReport() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: App.java    From UIWidget with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    sContext = this;
    CrashReport.initCrashReport(getApplicationContext());
    String appChannel = (String) SPUtil.get(getApplicationContext(), SPConstant.SP_KEY_APP_CHANNEL, "");
    Log.i("appChannel", "appChannel0:" + appChannel);
    if (TextUtils.isEmpty(appChannel)) {
        appChannel = CrashReport.getAppChannel();
        Log.i("appChannel", "appChannel1:" + appChannel);
        SPUtil.put(getApplicationContext(), SPConstant.SP_KEY_APP_CHANNEL, appChannel);
    } else {
        CrashReport.setAppChannel(getApplicationContext(), appChannel);
    }
    Log.i("appChannel", "appChannel2:" + appChannel);
    if (BuildConfig.DEBUG) {
        CrashReport.closeBugly();
    }
    if (LeakCanary.isInAnalyzerProcess(this)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    LeakCanary.install(this);
    registerActivityLifecycleCallbacks(this);
}
 
Example 2
Source File: MoeQuestApp.java    From MoeQuest with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {

  super.onCreate();
  mAppContext = this;
  // 配置Realm数据库
  RealmConfiguration configuration = new RealmConfiguration
      .Builder(this)
      .deleteRealmIfMigrationNeeded()
      .schemaVersion(6)
      .migration(new RealmMigration() {

        @Override
        public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {

        }
      }).build();

  Realm.setDefaultConfiguration(configuration);

  //配置腾讯bugly
  CrashReport.initCrashReport(getApplicationContext(), ConstantUtil.BUGLY_ID, false);
}
 
Example 3
Source File: InitializeService.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化腾讯bug管理平台
 */
private void initBugly() {
    /* Bugly SDK初始化
    * 参数1:上下文对象
    * 参数2:APPID,平台注册时得到,注意替换成你的appId
    * 参数3:是否开启调试模式,调试模式下会输出'CrashReport'tag的日志
    * 注意:如果您之前使用过Bugly SDK,请将以下这句注释掉。
    */
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(getApplicationContext());
    // 设置版本号
    strategy.setAppVersion(AppUtils.getAppVersionName());
    // 设置版本名称
    String appPackageName = AppUtils.getAppPackageName();
    strategy.setAppPackageName(appPackageName);
    // 获取当前进程名
    String processName = AppToolUtils.getProcessName(android.os.Process.myPid());
    // 设置是否为上报进程
    strategy.setUploadProcess(processName == null || processName.equals(appPackageName));
    //Bugly会在启动20s后联网同步数据
    strategy.setAppReportDelay(20000);
    //正式版
    CrashReport.initCrashReport(getApplicationContext(), "521262bdd7", false, strategy);
}
 
Example 4
Source File: PluginManager.java    From xposed-rimet with Apache License 2.0 5 votes vote down vote up
private PluginManager(Build build) {
    mContext = build.mContext;
    mLoadPackageParam = build.mLoadPackageParam;

    // 调试开关
    Alog.setDebug(BuildConfig.DEBUG);

    // 创建缓存管理
    mCacheManager = new CacheManager(mContext);

    // 创建配置管理对象
    mConfigManager = new ConfigManager
            .Build(this)
            .setConfigName(Constant.Name.RIMET)
            .build();

    // 获取版本管理对象
    mVersionManager = new VersionManager
            .Build(mContext)
            .setConfigManager(mConfigManager)
            .setCacheManager(mCacheManager)
            .build();

    mHandler = new PluginHandler();
    ToastUtil.getInstance().init(mContext);
    Picasso.setSingletonInstance(new Picasso.Builder(mContext).build());

    // 添加统计
    CrashReport.initCrashReport(mContext, "3f1c04b5b5", BuildConfig.DEBUG);
    CrashReport.setAppChannel(mContext, BuildConfig.FLAVOR);

    // 个别需要静态引用
    sXPluginManager = this;
}
 
Example 5
Source File: P2PApplication.java    From iMoney with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    mContext = this.getApplicationContext();
    LeakCanary.install(this);
    CommonApplication.initialize(this);
    OklaClient.getInstance().init(this);
    // 设置出现未捕获异常时的处理类
    //CrashHandler.getInstance().init();
    changeAppLanguage();

    // 初始化MobSDK
    MobSDK.init(this, "266ce6392d6fe", "6d4da648f3c2eef26eb682641d414c1c");

    /*
     * 第三个参数为SDK调试模式开关,调试模式的行为特性如下:
     * 输出详细的Bugly SDK的Log;
     * 每一条Crash都会被立即上报;
     * 自定义日志将会在Logcat中输出。
     * 建议在测试阶段建议设置成true,发布时设置为false。
     */
    CrashReport.initCrashReport(getApplicationContext(), "c84e7e9ad7", BuildConfig.DEBUG);

    initUETool();

    initGrowingIO();

    initJPushSdk();
}
 
Example 6
Source File: MyApplication.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    CrashReport.initCrashReport(getApplicationContext(), "4c251b8f40", false);
    LeakCanary.install(this);
}
 
Example 7
Source File: LazyLoadService.java    From fuckView with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void onHandleIntent(@Nullable Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        if (ACTION_LAZY_LOAD_SERVICE.equals(action)) {
            CrashReport.initCrashReport(getApplicationContext(), Constant.BUGLY_KEY, false);
        }
    }
}
 
Example 8
Source File: App.java    From Yuan-WanAndroid with Apache License 2.0 5 votes vote down vote up
private void initBugly() {
    Context context = getApplicationContext();
    // 获取当前包名
    String packageName = context.getPackageName();
    // 获取当前进程名
    String processName = CommonUtils.getProcessName(android.os.Process.myPid());
    // 设置是否为上报进程
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
    strategy.setUploadProcess(processName == null || processName.equals(packageName));
    // 初始化Bugly
    CrashReport.initCrashReport(context, Constant.BUGLY_APP_ID, false, strategy);

}
 
Example 9
Source File: MyApplication.java    From NetEasyNews with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 初始化bugly
 */
private void initBugly() {
// 获取当前包名
    String packageName = mContext.getPackageName();
// 获取当前进程名
    String processName = getProcessName(android.os.Process.myPid());
// 设置是否为上报进程
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(mContext);
    strategy.setUploadProcess(processName == null || processName.equals(packageName));
    CrashReport.initCrashReport(getApplicationContext(), "7a544c9222", false);
}
 
Example 10
Source File: WanAndroidApp.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
private void initBugly() {
    // 获取当前包名
    String packageName = getApplicationContext().getPackageName();
    // 获取当前进程名
    String processName = CommonUtils.getProcessName(android.os.Process.myPid());
    // 设置是否为上报进程
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(getApplicationContext());
    strategy.setUploadProcess(processName == null || processName.equals(packageName));
    CrashReport.initCrashReport(getApplicationContext(), Constants.BUGLY_ID, false, strategy);
}
 
Example 11
Source File: MyApplication.java    From Bugly-Android-Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

   /* Bugly SDK初始化
    * 参数1:上下文对象
    * 参数2:APPID,平台注册时得到,注意替换成你的appId
    * 参数3:是否开启调试模式,调试模式下会输出'CrashReport'tag的日志
    */
    CrashReport.initCrashReport(getApplicationContext(), "9ad897e06b", true);
}
 
Example 12
Source File: MyApp.java    From ImmersionBar with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    mContext = getApplicationContext();
    // bugly
    CrashReport.initCrashReport(getApplicationContext(), "31a5f1f394", false);
    // 网络监听服务
    NetworkService.enqueueWork(this);
    Fragmentation.builder()
            // 显示悬浮球 ; 其他Mode:SHAKE: 摇一摇唤出   NONE:隐藏
            .stackViewMode(Fragmentation.BUBBLE)
            .debug(BuildConfig.DEBUG)
            .install();
}
 
Example 13
Source File: Application.java    From CatchPiggy with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    //init bugly
    CrashReport.initCrashReport(this, "488e87756b", false);
}
 
Example 14
Source File: SmsCodeApp.java    From SmsCode with GNU General Public License v3.0 4 votes vote down vote up
private void initBugly() {
    CrashReport.initCrashReport(getApplicationContext(), "333c9e49e5", BuildConfig.DEBUG);
}
 
Example 15
Source File: CrashReportHelper.java    From Mysplash with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void init(Context context) {
    CrashReport.initCrashReport(context.getApplicationContext(), "c8ad99bd5d", false);
}
 
Example 16
Source File: EncyApplication.java    From Ency with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    instance = this;

    appComponent = DaggerAppComponent
            .builder()
            .applicationModule(new ApplicationModule(this))
            .httpModule(new HttpModule())
            .build();

    SharePrefManager sharePrefManager = appComponent.getSharePrefManager();

    boolean nightMode = sharePrefManager.getNightMode();
    AppCompatDelegate.setDefaultNightMode(nightMode ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);

    sharePrefManager.setLocalMode(AppCompatDelegate.getDefaultNightMode());
    sharePrefManager.setLocalProvincialTrafficPatterns(sharePrefManager.getProvincialTrafficPattern());

    // 初始化Bugly
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(getApplicationContext());
    strategy.setAppVersion(String.valueOf(AppApplicationUtil.getVersionCode(getApplicationContext())));
    CrashReport.initCrashReport(getApplicationContext(), Constants.BUGLY_APP_ID, false); // debug版本设置为true,正式发布设置为false

    // 初始化Fragmentation
    Fragmentation.builder()
            // 设置 栈视图 模式为 悬浮球模式   SHAKE: 摇一摇唤出  默认NONE:隐藏, 仅在Debug环境生效
            .stackViewMode(Fragmentation.BUBBLE)
            // 开发环境:true时,遇到异常:"Can not perform this action after onSaveInstanceState!"时,抛出,并Crash;
            // 生产环境:false时,不抛出,不会Crash,会捕获,可以在handleException()里监听到
            .debug(false)
            // 实际场景建议.debug(BuildConfig.DEBUG)
            // 生产环境时,捕获上述异常(避免crash),会捕获
            // 建议在回调处上传下面异常到崩溃监控服务器
            .handleException(new ExceptionHandler() {
                @Override
                public void onException(Exception e) {
                    CrashReport.postCatchedException(e);  // bugly会将这个Exception上报
                }
            })
            .install();

    //搜集本地tbs内核信息并上报服务器,服务器返回结果决定使用哪个内核。
    QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {
        @Override
        public void onViewInitFinished(boolean arg0) {
            //x5內核初始化完成的回调,为true表示x5内核加载成功,否则表示x5内核加载失败,会自动切换到系统内核。
            LogUtil.d("app", " onViewInitFinished is " + arg0);
        }

        @Override
        public void onCoreInitFinished() {

        }
    };
    //x5内核初始化接口
    QbSdk.initX5Environment(getApplicationContext(), cb);

    // 初始化LeakCanary
    if (LeakCanary.isInAnalyzerProcess(this)) {
        return;
    }
    LeakCanary.install(this);

    // 异常处理类
    if (!BuildConfig.DEBUG) {
        EncyCrashHandler.getInstance().setCrashHanler(this);
    }
}
 
Example 17
Source File: HApp.java    From styT with Apache License 2.0 4 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        BGASwipeBackHelper.init(this, null);
        if (isMainProcess()) {
            OpenInstall.init(this);
            OpenInstall.setDebug(true);
        }

        context = getApplicationContext();
/*
        Context context = getApplicationContext();
// 获取当前包名
        String packageName = context.getPackageName();
// 获取当前进程名
        String processName = getProcessName(android.os.Process.myPid());
// 设置是否为上报进程
        CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
        strategy.setUploadProcess(processName == null || processName.equals(packageName));
// 初始化Bugly
        CrashReport.initCrashReport(context, "34c3176b4a", false, strategy);
 */


        CrashReport.initCrashReport(getApplicationContext(), "34c31", false);
        SharedPreferencesUtil.getInstance(this, "TestBILI");
        Bmob.initialize(this, "", "dio");
        //Bmob.initialize(this, nico.GetPathFromUri4kitkat.jk("~#~~~……~、~_•%~~•~•&•%~&•%•&~&~~~¥~、~#~~~>•#~&~>~、~、~#~#~>~、•&•~•_"));
        // 使用推送服务时的初始化操作
        BmobInstallationManager.getInstance().initialize(new InstallationListener<BmobInstallation>() {
            @Override
            public void done(BmobInstallation bmobInstallation, BmobException e) {
                // if (e == null) {
                //Logger.i(bmobInstallation.getObjectId() + "-" + bmobInstallation.getInstallationId());
                // } else {
                // Logger.e(e.getMessage());
                // }
            }
        });
// 启动推送服务
        BmobPush.startWork(this);
        MobSDK.init(this, this.a(), this.b());
        //初始化辅助功能基类
        BaseAccessibilityService.getInstance().init(getApplicationContext());
        SettingConfig.getInstance().init(getApplicationContext());
        //Exce handler = Exce.getInstance(this);
        //Thread.setDefaultUncaughtExceptionHandler(handler);

        // 异常处理,不需要处理时注释掉这两句即可!
        //CrashHandler crashHandler = CrashHandler.getInstance();
        // 注册crashHandler
        //crashHandler.init(getApplicationContext());
    }
 
Example 18
Source File: CaptureApplication.java    From CapturePacket with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    CrashReport.initCrashReport(getApplicationContext(), "bf984fa8b1", BuildConfig.DEBUG);
}
 
Example 19
Source File: AppContext.java    From renrenpay-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    instance = this;
    configManager = ConfigManager.getInstance();
    CrashReport.initCrashReport(getApplicationContext(), "7b37c18319", false);
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .connectTimeout(10000L, TimeUnit.MILLISECONDS)
            .readTimeout(10000L, TimeUnit.MILLISECONDS)
            //其他配置
            .build();
    String processAppName = getAppName(android.os.Process.myPid());
    // 如果APP启用了远程的service,此application:onCreate会被调用2次
    // 为了防止被初始化2次,加此判断会保证SDK被初始化1次
    // 默认的APP会在以包名为默认的process name下运行,如果查到的process name不是APP的process name就立即返回
    if (processAppName == null || !processAppName.equalsIgnoreCase(this.getPackageName())) {
        // 则此application::onCreate 是被service 调用的,直接返回
        return;
    }

    instance = this;
    // 程序崩溃时触发线程  以下用来捕获程序崩溃异常并重启应用
    Thread.setDefaultUncaughtExceptionHandler(restartHandler);
    HookList.getInstance();
    registerReceiver(new ReceiverMain(), new IntentFilter(HookBase.RECV_ACTION));
    OkHttpUtils.initClient(okHttpClient);
    accountManager = new AccountManager();
    Log.d(TAG, accountManager.toString());
    int id = accountManager.getUserId();
    if(id == 0) {
        id = configManager.getInt("id", 0);
    }
    if (accountManager.isLogined()) {
        User user = UserDao.findById(id);

        if(user != null)
            setUser(user);
        else
            accountManager.setLogined(false);
    }
}
 
Example 20
Source File: InitBuglyTask.java    From android-performance with MIT License 4 votes vote down vote up
@Override
public void run() {
    CrashReport.initCrashReport(mContext, "注册时申请的APPID", false);
}