com.tencent.bugly.crashreport.CrashReport Java Examples

The following examples show how to use com.tencent.bugly.crashreport.CrashReport. 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: MyApplication.java    From v9porn with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    myApplication = this;
    initNightMode();
    AppLogger.initLogger();
    initLeakCanary();
    initLoadingHelper();
    initFileDownload();
    if (!BuildConfig.DEBUG) {
        //初始化bug收集
      //  Bugsnag.init(this);
    }
    CrashReport.initCrashReport(getApplicationContext(), "e426041d83", BuildConfig.DEBUG);
    BGASwipeBackHelper.init(this, null);
}
 
Example #2
Source File: LoginFragment.java    From AccountBook with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void showLoginSuccess() {
    final User user = UserUtils.getUser();
    String objectId = user.getObjectId();
    createDefaultType(objectId);
    CrashReport.setUserId(objectId);
    final AccountRepository repository = new AccountRepository();
    repository.queryDefaultBook(user, new AccountDataSource.QueryDefaultBookCallback() {
        @Override
        public void querySuccess(AccountBook book) {
            ProgressUtils.dismiss();
            ToastUtils.show(mContext, UiUtils.getString(R.string.toast_login_success));
            UiUtils.enterHomePage(mContext);
        }

        @Override
        public void queryFail(Error e) {
            ProgressUtils.dismiss();
            ToastUtils.show(mContext, UiUtils.getString(R.string.toast_login_fail));
        }
    });
}
 
Example #3
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 #4
Source File: MyApplication.java    From v9porn with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    myApplication = this;
    initNightMode();
    AppLogger.initLogger();
    initLeakCanary();
    initLoadingHelper();
    initFileDownload();
    if (!BuildConfig.DEBUG) {
        //初始化bug收集
      //  Bugsnag.init(this);
    }
    CrashReport.initCrashReport(getApplicationContext(), "e426041d83", BuildConfig.DEBUG);
    BGASwipeBackHelper.init(this, null);
}
 
Example #5
Source File: AppApplication.java    From OpenHub with GNU General Public License v3.0 6 votes vote down vote up
private void initBugly(){

        Beta.initDelay = 6 * 1000;
        Beta.enableHotfix = false;
        Beta.canShowUpgradeActs.add(LoginActivity.class);
        Beta.canShowUpgradeActs.add(MainActivity.class);
        Beta.canShowUpgradeActs.add(AboutActivity.class);
        Beta.upgradeListener = UpgradeDialog.INSTANCE;

        CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(getApplicationContext());
        strategy.setAppVersion(BuildConfig.VERSION_NAME);
        strategy.setAppChannel(getAppChannel());
        strategy.setAppReportDelay(10 * 1000);
        Bugly.init(getApplicationContext(), AppConfig.BUGLY_APPID, BuildConfig.DEBUG, strategy);
        CrashReport.setIsDevelopmentDevice(getApplicationContext(), BuildConfig.DEBUG);

    }
 
Example #6
Source File: BaseApplication.java    From shinny-futures-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * date: 2019/6/18
 * author: chenli
 * description: 配置bugly
 */
private void initBugly(String BUGLY_KEY){
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(sContext);
    strategy.setCrashHandleCallback(new CrashReport.CrashHandleCallback() {
        public Map<String, String> onCrashHandleStart(int crashType, String errorType,
                                                      String errorMessage, String errorStack) {
            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject.put(AMP_EVENT_CRASH_TYPE, crashType);
                jsonObject.put(AMP_EVENT_ERROR_TYPE, errorType);
                jsonObject.put(AMP_EVENT_ERROR_MESSAGE, errorMessage);
                jsonObject.put(AMP_EVENT_ERROR_STACK, errorStack);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            Amplitude.getInstance().logEventWrap(AMP_CRASH, jsonObject);
            LinkedHashMap<String, String> map = new LinkedHashMap<>();
            map.put("user-agent", sDataManager.USER_AGENT);
            return map;
        }
    });
    Beta.enableHotfix = false;
    Bugly.init(sContext, BUGLY_KEY, false, strategy);
}
 
Example #7
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 #8
Source File: MyApplication.java    From Mobike with Apache License 2.0 6 votes vote down vote up
private void initMyApplication() {
    //tencent bugly
    CrashReport.initCrashReport(getApplicationContext(), "e1a62089c6", false);
    //Fresco
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
            .build();
    Fresco.initialize(this, config);
    //baidu map sdk
    SDKInitializer.initialize(this);
    //Bmob
    Bmob.initialize(this, "b0cb494256d9b86fc931ca930a055b75");
    //Logger
    Logger.addLogAdapter(new AndroidLogAdapter(){
        @Override
        public boolean isLoggable(int priority, String tag) {
            return true;// TODO: 2017/6/5
        }
    });
    //locail use data
    initUser();
}
 
Example #9
Source File: CaptureService.java    From CapturePacket with MIT License 6 votes vote down vote up
@Override
public void run() {
    try {
        mProxyServer = new BrowserMobProxyServer(mKeyStoreDir);
        mProxyServer.setTrustAllServers(true);
        mProxyServer.start(PROXY_PORT);

        mProxyServer.enableHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.REQUEST_COOKIES,
                CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_HEADERS, CaptureType.REQUEST_COOKIES,
                CaptureType.RESPONSE_CONTENT);

        String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA)
                .format(new Date(System.currentTimeMillis()));
        mProxyServer.newHar(time);
        mProxyState = STATE_SUCCESS;

    }catch (Throwable e){
        CrashReport.postCatchedException(e);
        mProxyState = STATE_FAIL;
    }
    if (mCaptureBinder != null) {
        mCaptureBinder.setProxyServer(mProxyServer);
        mCaptureBinder.setProxyState(mProxyState);
    }

}
 
Example #10
Source File: RongRTCApplication.java    From sealrtc-android with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Utils.init(this);
    // bugly 配置,查看对应崩溃日志。
    String processName = Utils.getCurProcessName(this);
    // 设置是否为上报进程
    CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(this);
    strategy.setUploadProcess(processName.equals(getPackageName()));
    // 初始化Bugly
    CrashReport.initCrashReport(this, "3612cc23a8", false, strategy);
    if (getApplicationInfo().packageName.equals(Utils.getCurProcessName(this))) {
      try {
        RongIMClient.registerMessageType(RoomInfoMessage.class);
        RongIMClient.registerMessageType(WhiteBoardInfoMessage.class);
        RongIMClient.registerMessageType(RoomKickOffMessage.class);
      } catch (AnnotationNotFoundException e) {
        e.printStackTrace();
      }

      // 相芯SDK 初始化
      FURenderer.initFURenderer(this);
    }

    registerLifecycleCallbacks();
}
 
Example #11
Source File: MyApplication.java    From PicKing with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .build();
    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(this, okHttpClient)
            .setMainDiskCacheConfig(getDiskCacheConfig())
            .setNetworkFetcher(new OkHttpNetworkFetcher(okHttpClient))
            .setDownsampleEnabled(true)
            .build();
    Fresco.initialize(this, config);

    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));
    CrashReport.initCrashReport(getApplicationContext(), "0a6e92fb70", false, strategy);

    registerActivityLifecycleCallbacks(ActivityLifecycleHelper.build());
}
 
Example #12
Source File: App.java    From APlayer with GNU General Public License v3.0 6 votes vote down vote up
private void loadLibrary() {
  // bugly
  Context context = getApplicationContext();
  // 获取当前包名
  String packageName = context.getPackageName();
  // 获取当前进程名
  String processName = Util.getProcessName(android.os.Process.myPid());
  // 设置是否为上报进程
  UserStrategy strategy = new UserStrategy(context);
  strategy.setUploadProcess(processName == null || processName.equals(packageName));
  CrashReport.initCrashReport(this, BuildConfig.BUGLY_APPID, BuildConfig.DEBUG, strategy);
  CrashReport.setIsDevelopmentDevice(this, BuildConfig.DEBUG);

  // fresco
  final int cacheSize = (int) (Runtime.getRuntime().maxMemory() / 8);
  ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
      .setBitmapMemoryCacheParamsSupplier(
          () -> new MemoryCacheParams(cacheSize, Integer.MAX_VALUE, cacheSize, Integer.MAX_VALUE,
              2 * ByteConstants.MB))
      .setBitmapsConfig(Bitmap.Config.RGB_565)
      .setDownsampleEnabled(true)
      .build();
  Fresco.initialize(this, config);

}
 
Example #13
Source File: MyApplication.java    From Android-Plugin-Framework with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();

       //bugly SDK
       CrashReport.initCrashReport(getApplicationContext(), "c38ae3f8a6", true);

       //UMENG SDK
       //MobclickAgent.setDebugMode(true);
       //MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);

       FairyGlobal.setLogEnable(true);
       FairyGlobal.setLocalHtmlenable(false);
       FairyGlobal.setLoadingResId(R.layout.loading);

       //Just for test custom Mapping Processor
       FairyGlobal.registStubMappingProcessor(new TestCoustProcessor());
}
 
Example #14
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 #15
Source File: App.java    From APlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  mContext = this;

  if (!BuildConfig.DEBUG) {
    IS_GOOGLEPLAY = "google".equalsIgnoreCase(Util.getAppMetaData("BUGLY_APP_CHANNEL"));
  }

  setUp();

  // AppShortcut
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
    new DynamicShortcutManager(this).setUpShortcut();
  }

  // 加载第三方库
  loadLibrary();

  // 处理 RxJava2 取消订阅后,抛出的异常无法捕获,导致程序崩溃
  RxJavaPlugins.setErrorHandler(throwable -> {
    Timber.v(throwable);
    CrashReport.postCatchedException(throwable);
  });

  registerActivityLifecycleCallbacks(this);
}
 
Example #16
Source File: BookBoxApplication.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        appContext = this;
        Timber.plant(new Timber.DebugTree());
        ToastHelper.init(this);
        Dexter.initialize(this);
        gson = new Gson();
        preferenceUtils = new SharedPreferenceUtils(this);
        handler = new Handler();
//        CrashHandler.getInstance().init(this.getApplicationContext());
        CrashReport.initCrashReport(getApplicationContext(), "900028744", BuildConfig.DEBUG);

        initPush();
    }
 
Example #17
Source File: MainActivity.java    From OpenHub with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void initActivity() {
    super.initActivity();
    if (AppData.INSTANCE.getLoggedUser() != null)
        CrashReport.putUserData(getApplicationContext(),
                "GitHubId", AppData.INSTANCE.getLoggedUser().getLogin());

    setStartDrawerEnable(true);
    setEndDrawerEnable(true);
    newYearWishesDialog = new NewYearWishesDialog(getActivity());
    newYearWishesDialog.checkStarWishes();
}
 
Example #18
Source File: MainActivity.java    From Bugly-Android-Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btnTestJavaCrash: // 点击测试Java Crash
            CrashMock.mockJavaCrash();
            break;
        case R.id.btnTestANRCrash: // 点击测试ANR Crash
            CrashReport.testANRCrash();
            break;
        case R.id.btnTestNativeCrash: // 点击测试Native Crash
            CrashReport.testNativeCrash();
            break;
    }
}
 
Example #19
Source File: MyApplication.java    From Android-Tech with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    // 最简单的初始化,Bugly2.0及以上版本还支持通过“AndroidManifest.xml”来配置APP信息
    // CrashReport.initCrashReport(getApplicationContext(), "注册时申请的APPID", false);
    CrashReport.initCrashReport(getApplicationContext(), "900029763", false);

    // 测试crash
    CrashReport.testJavaCrash();
}
 
Example #20
Source File: BaseAppCompatActivity.java    From fuckView with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void startActivity(Intent intent, @Nullable Bundle options) {
    try {
        super.startActivity(intent, options);
    } catch (ActivityNotFoundException e) {
        CrashReport.postCatchedException(e);
    }
}
 
Example #21
Source File: BaseApplication.java    From allenglish with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    app = this;

    // 设置默认字体
    FontsOverride.setDefaultFont(app, "MONOSPACE", "fonts/MILT_RG.ttf");

    // Bugly
    CrashReport.initCrashReport(app, "bcd6831e61", false);

    PreferencesUtils.putString(app, "sentence", Constants.DEFAULT_HISTORY_JSON);
}
 
Example #22
Source File: MyApplication.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
    application = this;
    LitePalApplication.initialize(context);
    CrashReport.initCrashReport(getApplicationContext(), "398dc6145b", false);
    AndroidThreeTen.init(this);

}
 
Example #23
Source File: App.java    From Ruisi with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
    //初始化http
    HttpUtil.init(getApplicationContext());

    //清空消息数据库
    MyDB myDB = new MyDB(context);
    //最多缓存2000条历史纪录
    myDB.deleteOldHistory(2000);

    SharedPreferences shp = PreferenceManager.getDefaultSharedPreferences(context);
    // 自定义外网睿思服务器地址
    String customOutServerAddr = shp.getString("setting_rs_out_server_addr", App.BASE_URL_ME).trim();
    if (customOutServerAddr.length() > 0) {
        if (!customOutServerAddr.startsWith("http://")) {
            customOutServerAddr = "http://" + customOutServerAddr;
        }

        if (!customOutServerAddr.endsWith("/")) {
            customOutServerAddr += "/";
        }

        Log.i("APP", "设置外网服务器地址:" + customOutServerAddr);
        BASE_URL_ME = customOutServerAddr;
    }

    regReceiver();

    CrashReport.initCrashReport(getApplicationContext(), "04a96747f8", false);
}
 
Example #24
Source File: MyApplication.java    From Android-Tech with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    // 初始化Bugly崩溃捕获
    CrashReport.initCrashReport(getApplicationContext(), "900029763", false);

}
 
Example #25
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 #26
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 #27
Source File: HomeActivity.java    From Android with MIT License 5 votes vote down vote up
@Override
public void initView() {
    activity = this;
    setDefaultFragment();

    UserBean userBean = SharedPreferenceUtil.getInstance().getUser();
    SharePreferenceUser.initSharePreferrnce(userBean.getPubKey());
    HttpsService.startService(activity);

    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            Session.getInstance().clearUserCookie();
            DaoManager.getInstance().closeDataBase();
            DaoManager.getInstance().switchDataBase();
            FileUtil.getExternalStorePath();

            CrashReport.putUserData(activity, "userAddress", MemoryDataManager.getInstance().getAddress());
            CrashReport.setUserSceneTag(activity, Integer.valueOf(ConfigUtil.getInstance().getCrashTags()));
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
            LogManager.getLogger().d(Tag, "onPostExecute");

            ConnectState.getInstance().sendEvent(ConnectState.ConnectType.CONNECT);
            requestAppUpdata();
            checkWebOpen();
        }
    }.execute();
}
 
Example #28
Source File: BaseApplication.java    From Android with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    mApplication = this;

    EmoManager.getInstance();
    UnCeHandler catchExcep = new UnCeHandler(this);
    Thread.setDefaultUncaughtExceptionHandler(catchExcep);
    CrashReport.initCrashReport(this, ConfigUtil.getInstance().getCrashAPPID(), true);
}
 
Example #29
Source File: MyApplication.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    app = this;
    //初始化屏幕宽高
    getScreenSize();

    CrashReport.initCrashReport(getApplicationContext(), "c73ecc54da", false);
}
 
Example #30
Source File: MyApplication.java    From music_player with Open Software License 3.0 5 votes vote down vote up
private void initialBugly() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            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));
            Beta.initDelay = 3000;
            Bugly.init(context, "1d65abe1b1", false);

        }
    }).start();
}