When the Activity’s launch mode is singleTask or singleInstance. If an intent is used to pass a value, then the problem may arise that the intent’s value cannot be updated. That is, the value received for each Intent is the value received for the first time. Because the intent has not been updated. To update, you need to do two things.
1. Add a sentence to the sender Activity
PendingIntent pendingIntent = PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
2. The receiving Activity, plus a function, calls the method setIntent
protected void onNewIntent(Intent intent) { Log.i(TAG,"onNewIntent()"); super.onNewIntent(intent); setIntent(intent); int value = getIntent().getIntExtra("value_key", 0); Log.i(TAG,"value = "+value); }
Reproduced in: https://www.cnblogs.com/davesuen/p/3703436.html
Read More:
- The intent solution cannot be updated in onrestart method
- The problem that the content extra data in the notification cannot be updated
- Error receiving broadcast Intent { act=com.supersdk.listen.PayListen_defeat flg=0x10 (has extras)
- Android can’t transfer value when using extras, bundle and intent
- Get the startup activity of Android apk
- Javabinder:
- Android: Web access activity error: error unknown URL scheme
- XML tag has empty body less… (Ctrl+F1) Reports empty tag body. The validation works in XML / JSP
- Error record: this.requestWindowFeature ( Window.FEATURE_ NO_ Title) error or no effect
- Postgressql: cannot drop the currently open database
- An error is reported for the new Android project. Rejecting re init on previously failed
- Android has applied for permission and still prompts open failed: eacces (permission denied)
- Android set request window feature( Window.FEATURE_ NO_ Title) invalid solution
- Unknown error (SQLite code 14): could not open database (How to Fix)
- How to solve the problem of “blocked loading mixed active content” in Firefox
- Android avoids memory leak: reasonable use of getcontext() and getapplication ()
- Session app error launching activity solution
- Problems in the second day of Android learning
- Request window feature for Android Development( Window.FEATURE_ NO_ Title) does not take effect
- Android android.intent.category Purpose and use of. Launcher