APP启动优化(不优化部分手机打开会直接ANR,简直没法看)
This commit is contained in:
@@ -52,6 +52,7 @@ import com.netease.nimlib.sdk.mixpush.NIMPushClient;
|
||||
import com.netease.nimlib.sdk.msg.MessageNotifierCustomization;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.nimlib.sdk.util.NIMUtil;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.orhanobut.logger.AndroidLogAdapter;
|
||||
import com.orhanobut.logger.Logger;
|
||||
@@ -233,9 +234,9 @@ public class XChatApplication extends Application {
|
||||
}
|
||||
BasicConfig.INSTANCE.setChannel(channel);
|
||||
|
||||
LogUtils.d(channel + "");
|
||||
initEnv();
|
||||
|
||||
ActivityMgr.INST.init((Application) context);
|
||||
//延迟初始化云信
|
||||
NIMClient.init(context, null, options());
|
||||
|
||||
@@ -276,50 +277,40 @@ public class XChatApplication extends Application {
|
||||
//fixed: Glide Exception:"You must not call setTag() on a view Glide is targeting"
|
||||
ViewTarget.setTagId(R.id.tag_glide);
|
||||
|
||||
|
||||
init(channel);
|
||||
|
||||
if (!TextUtils.isEmpty(channel)) {
|
||||
CrashReport.setAppChannel(context, channel);
|
||||
}
|
||||
|
||||
initBuglyUpdate();
|
||||
Bugly.init(context, BuildConfig.DEBUG ? XChatConstants.BUGLY_KEY_DEBUG : XChatConstants.BUGLY_KEY_RELEASE, BuildConfig.DEBUG);
|
||||
if (!TextUtils.isEmpty(channel)) {
|
||||
Bugly.setAppChannel(context, channel);
|
||||
}
|
||||
|
||||
//生命周期监听
|
||||
if (lifeManager == null) {
|
||||
lifeManager = new ActivityLifeManager();
|
||||
}
|
||||
registerActivityLifecycleCallback(lifeManager);
|
||||
|
||||
|
||||
}
|
||||
dealHuaWeiCrash();
|
||||
|
||||
if (BuildConfig.APPLICATION_ID.equals(getProcessName(context))) {
|
||||
FlutterBoost.instance().setup((Application) context.getApplicationContext(), new XplanFlutterBoostDelegate(), new XplanFlutterBoostCallback());
|
||||
dealHuaWeiCrash();
|
||||
initLinkedMe();
|
||||
LinkedME.getInstance().setImmediate(true);
|
||||
MobSDK.init(context);
|
||||
MobSDK.submitPolicyGrantResult(true, null);
|
||||
// 友盟统计初始化
|
||||
UMConfigure.init(context, XChatConstants.UMENG_APP_KEY,
|
||||
BasicConfig.INSTANCE.getChannel(), UMConfigure.DEVICE_TYPE_PHONE, null);
|
||||
// 选用MANUAL页面采集模式
|
||||
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.MANUAL);
|
||||
// 支持在子进程中统计自定义事件
|
||||
UMConfigure.setProcessEvent(true);
|
||||
// 日志加密
|
||||
UMConfigure.setEncryptEnabled(true);
|
||||
// 集成测试
|
||||
UMConfigure.setLogEnabled(BuildConfig.DEBUG);
|
||||
//实人认证
|
||||
new Thread(() -> RPVerify.init(context)).start();
|
||||
}
|
||||
initLinkedMe();
|
||||
ActivityMgr.INST.init((Application) context);
|
||||
LinkedME.getInstance().setImmediate(true);
|
||||
MobSDK.init(context);
|
||||
MobSDK.submitPolicyGrantResult(true, null);
|
||||
// 友盟统计初始化
|
||||
UMConfigure.init(context, XChatConstants.UMENG_APP_KEY,
|
||||
BasicConfig.INSTANCE.getChannel(), UMConfigure.DEVICE_TYPE_PHONE, null);
|
||||
// 选用MANUAL页面采集模式
|
||||
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.MANUAL);
|
||||
// 支持在子进程中统计自定义事件
|
||||
UMConfigure.setProcessEvent(true);
|
||||
// 日志加密
|
||||
UMConfigure.setEncryptEnabled(true);
|
||||
// 集成测试
|
||||
UMConfigure.setLogEnabled(BuildConfig.DEBUG);
|
||||
//实人认证
|
||||
RPVerify.init(context);
|
||||
|
||||
LogUtils.d("init time = " + (System.currentTimeMillis() - startTime) + "ms");
|
||||
|
||||
}
|
||||
@@ -455,7 +446,7 @@ public class XChatApplication extends Application {
|
||||
*/
|
||||
private static boolean inMainProcess(Context context) {
|
||||
String packageName = context.getPackageName();
|
||||
String processName = getProcessName(context);
|
||||
String processName = NIMUtil.getProcessName(context);
|
||||
return packageName.equals(processName);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user