由于MainAcitity.class使用的是singleTask启动模式,所以别的Activity跳转到MainActivity.class后所带的参数(Intent & Bundle)均为null,这个是因为:
Bundle bundle = getIntent().getExtras();
这些方法不是在onCreate()中,所以不会加载的。
<pre name="code" class="java">想要得到这些值,这些方法必须放在:onNewIntent(Intent intent) 中:
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// Log.e("MainActiviy","onNewIntent");
// receiveBroadCaseMsg();
// Intent intent1 = getIntent();
Bundle bundle = intent.getExtras();
if(null !=bundle) {
String title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
String content = bundle.getString(JPushInterface.EXTRA_ALERT);
Log.e("ybb", "标题" + title + "内容" + content);
}
}
Bundle bundle = intent.getExtras(); if( null !=bundle) { String title = bundle.getString(JPushInterface. EXTRA_NOTIFICATION_TITLE); String content = bundle.getString(JPushInterface. EXTRA_ALERT); Log. e( "ybb", "标题" + title + "内容" + content); } }