我通過alarmreceiver,從服務類傳遞一個掛起的意圖。但是,在pendingIntent觸發後,broadcastreceiver類不會收到intent.putExtra()信息。這裏是我的燒製的PendingIntentintent.putExtra()在等待意圖不起作用
Intent aint = new Intent(getApplicationContext(), AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), id, aint, PendingIntent.FLAG_UPDATE_CURRENT);
aint.putExtra("msg", msg);
aint.putExtra("phone", phone);
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
代碼報警接收機類低於
public String msg, phonen;
@Override
public void onReceive(Context context, Intent intent){
Bundle extras = intent.getExtras();
msg = extras.getString("msg");
phonen = extras.getString("phone");
Log.d("onReceive", "About to execute MyTask");
Toast.makeText(context,msg, Toast.LENGTH_LONG).show();
}
在敬酒味精信息,正從待定的意圖收到的,不被顯示。相反,顯示一個空白的吐司。
對於那些希望在這個並有連接到的PendingIntent前.putExtra方法,該'PendingIntent.FLAG_UPDATE_CURRENT'是很重要的,所以嘗試上移動到另一個解決方案之前。 – DonutGaz