如何從額外的意圖'清理'值?BroadcastReceiver的意圖無法正常工作
活動:
@Override
public void onCreate(Bundle savedInstanceState) {
...
Intent intent = new Intent(this, MyBroadcastReceiver .class);
intent.putExtra("valueOne", "valOne");
intent.putExtra("valueTwo", true);
intent.putExtra("valueThree", 1);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
this.getApplicationContext(), 234324243, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
+ (5 * 1000), pendingIntent);
...
}
廣播接收器:
@Override
public void onReceive(Context context, Intent intent) {
...
String valueOne= intent.getStringExtra("valueOne");
Boolean valueTwo= intent.getBooleanExtra("valueTwo", false);
Integer valueThree= intent.getIntExtra("valueThree", 0);
// Log.i("info", valueOne) >> valOne
// Log.i("info", valueTwo.toString()) >> false
// Log.i("info", valueThree.toString()) >> 1
...
}
如果我更改了活動的值,然後再次運行應用程序時,我得到這樣相同的值在第一次開始。我試着從我的手機/虛擬機,清潔項目中刪除應用程序,但問題留:(
有人幫我