APP闲置1晚,点击推送通知
预期:转到片段
想更多地了解这次崩溃的原因
以下是崩溃日志:
USER_COMMENT=null ANDROID_VERSION=4.2.2 APP_VERSION_NAME=1.0.10 BRAND=Xiaomi PHONE_MODEL=2013023 CUSTOM_DATA= STACK_TRACE=java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aimpact.android/com.aimpact.android.AppMainActivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2346) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2398) at android.app.ActivityThread.access$600(ActivityThread.java:162) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5356) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:417) at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:452) at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:444) at com.aimpact.android.module.core.CoreActivity.pushFragment(CoreActivity.java:111) at com.aimpact.android.AppMainActivity.tryViewGCM(AppMainActivity.java:864) at com.aimpact.android.AppMainActivity.tryReceivingBackgroundGCM(AppMainActivity.java:842) at com.aimpact.android.AppMainActivity.onCreate(AppMainActivity.java:312) at android.app.Activity.performCreate(Activity.java:5226) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) at com.lbe.security.service.core.client.b.x.callActivityOnCreate(Unknown Source) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2310) ... 11 more java.lang.NullPointerException at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:417) at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:452) at android.support.v4.app.BackStackRecord.replace(BackStackRecord.java:444) at com.aimpact.android.module.core.CoreActivity.pushFragment(CoreActivity.java:111) at com.aimpact.android.AppMainActivity.tryViewGCM(AppMainActivity.java:864) at com.aimpact.android.AppMainActivity.tryReceivingBackgroundGCM(AppMainActivity.java:842) at com.aimpact.android.AppMainActivity.onCreate(AppMainActivity.java:312) at android.app.Activity.performCreate(Activity.java:5226) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) at com.lbe.security.service.core.client.b.x.callActivityOnCreate(Unknown Source) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2310) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2398) at android.app.ActivityThread.access$600(ActivityThread.java:162) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5356) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) at dalvik.system.NativeStart.main(Native Method)
我的Activity的Android代码是这样的:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
instance = this;
setLanguage(null);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
initNavBar();
initDrawer();
initTabBar();
resetNavButton();
onChangeFragment(null);
if (savedInstanceState == null) {
AppMainActivityInitDecider.decide(this);
}
onMISC("UDID: " + Helpers.getUDID());
onMISC("SECRET: " + Helpers.getAppSecret());
tryReceivingBackgroundGCM();
tryRegistrationGCM();
mgr = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
registerReceiver(onComplete,
new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
registerReceiver(onNotificationClick,
new IntentFilter(DownloadManager.ACTION_NOTIFICATION_CLICKED));
}
public void tryReceivingBackgroundGCM()
{
Log.e("GCM", "tryReceivingBackgroundGCM");
if (getIntent() != null) {
AimpactGCMModel gcm = (AimpactGCMModel) getIntent().getSerializableExtra("GCM_INTENT_FROM_BACKGROUND");
if (gcm != null) {
Log.e("GCM", "tryReceivingBackgroundGCM TRUE!");
tryViewGCM(gcm);
}
}
}
public void tryViewGCM(AimpactGCMModel model) {
Fragment fragment = NotificationActivityRouter.ManipulateEvent(model.getType(), model.getCode());
pushFragment(fragment);
}
public static Fragment ManipulateEvent(String eventType, String code)
{
if (eventType == null || code == null) return null;
if (eventType.startsWith("1")) {
ProfilePageFragment fragment = ProfilePageFragment.newInstance(code);
return fragment;
} else if (eventType.startsWith("2")) {
ProfilePageFragment fragment = ProfilePageFragment.newInstance(code, true);
return fragment;
} else if (eventType.startsWith("3")) {
ProfilePageFragment fragment = ProfilePageFragment.newInstance(code);
return fragment;
} else if (eventType.startsWith("4")) {
WallSinglePageFragment fragment = WallSinglePageFragment.newInstance(code, AimpactConstants.PostType.STATUS_MESSAGE);
return fragment;
} else if (eventType.startsWith("5")) {
if (eventType.startsWith("5001")
|| eventType.startsWith("5002")
|| eventType.startsWith("5003")) {
// news
WallSinglePageFragment fragment = WallSinglePageFragment.newInstance(code, AimpactConstants.PostType.NEWS);
return fragment;
} else if (eventType.startsWith("5004")) {
// commentary
WallSinglePageFragment fragment = WallSinglePageFragment.newInstance(code, AimpactConstants.PostType.COMMENTARY);
return fragment;
}
} else if (eventType.startsWith("6")) {
if (eventType.startsWith("6001")
|| eventType.startsWith("6003")) {
// stock
StocksPageFragment fragment = StocksPageFragment.newInstance(code);
return fragment;
} else if (eventType.startsWith("6002")) {
// analyst
ProfilePageFragment fragment = ProfilePageFragment.newInstance(code);
return fragment;
}
}
return null;
}
public void pushFragment(Fragment instance)
{
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, instance).addToBackStack(null).commit(); <<< seems this line crash ?
curFragmentCount += 1;
onChangeFragment(instance);
}
有人可以帮助我吗?