为什么brocastreceiver接受不到inent呢?
activity类for (int k = 1; k <= times; k++) {
Date thisDate = new Date(year, month, day, hour
, minute+1*(k-1), 0);
SimpleDateFormat mFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Log.e("TAG",mFormat.format(thisDate));
Intent mIntent = new Intent(context, AlarmReceiver.class);
mIntent.setAction("action.AlarmReceiver");
mIntent.putExtra("date", mFormat.format(thisDate));
PendingIntent mPendingIntent = PendingIntent.getBroadcast(context,
0, mIntent, 0);
AlarmManager mAlarmManager = myManager;
mAlarmManager.set(AlarmManager.RTC_WAKEUP, thisDate.getTime(), mPendingIntent);
}
receiver类
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "AlarmReceiver.onReceive");
String date = intent.getStringExtra("date");
Log.e(TAG, date);
SimpleDateFormat mFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
}
logcat:
12-18 12:57:10.467: E/MeActivity(4649): indicator:1
12-18 12:57:10.497: E/TAG(4649): 2011-12-18 12:53
12-18 12:57:10.577: E/AlarmReceiver(4649): AlarmReceiver.onReceive
12-18 12:57:10.577: E/AlarmReceiver(4649): 2011-12-18 12:43
12-18 12:57:10.587: E/AlarmReceiver(4649): intentdate=Sun Dec 18 12:43:00 格林尼治标准时间+0800 2011
12-18 12:57:10.587: E/AlarmReceiver(4649): presentdate=Sun Dec 18 12:57:10 格林尼治标准时间+0800 2011
可以看到,附在intent里的date发的时候是12:53,怎么接受了就成了12:43了,另外,不管发的时间是多少,接受到的都是12:43?或者是压根没接收到intent,只不过是默认为12:43···
补充:移动开发 , Android