我嘗試了一切在stackOverflow中建議 - 沒有任何幫助。 通知工作正常,它只是失去它的捆綁。來自待定意圖的Android捆綁包總是接收爲空
這裏是我的PendingIntent:
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(this, LoginActivity.class);
// Intent intent = new Intent().setClass(this, LoginActivity.class);
intent.putExtra(Constants.KEY_BUNDLE_MESSAGE_FROM_NOTIFICATION,true);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//intent.setAction("dummy");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder noBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(title)
.setContentText(text)
/* .setStyle(new NotificationCompat.BigTextStyle()
.bigText(message))*/
.setAutoCancel(true)
.setContentIntent(contentIntent);
notificationManager.notify(0, noBuilder.build());
1)將採取行動的意圖:intent.setAction( 「啞」);
2)將setClass添加到Intent:.setClass(this,LoginActivity.class);
3)待定意圖嘗試了所有的標誌:PendingIntent.FLAG_UPDATE_CURRENT/FLAG_CANCEL_CURRENT/FLAG_ONE_SHOT/0
4)試圖在recieving recieving在兩個 「onNewIntent」 中和 「的onCreate」 的額外
的額外活動始終是假
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.d(TAG, "im in login from notification! "+ intent.hasExtra(Constants.KEY_BUNDLE_MESSAGE_FROM_NOTIFICATION));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Intent intent = getIntent();
Log.d(TAG, "im in login from notification! "+ intent.hasExtra(Constants.KEY_BUNDLE_MESSAGE_FROM_NOTIFICATION));
}
什麼想法? 謝謝!
在'onNewIntent'補充:'setIntent(意向)' –
仍然有在日誌中虛假一如既往.. – Marv1n
你的代碼看起來沒什麼問題的。請發佈清單 –