80,351
社区成员
发帖
与我相关
我的任务
分享
Intent intent=new Intent(context,AlarmReceiver.class);//context,AlarmReceiver.class
intent.setAction("com.example.mischedule.alarm_first_action");//"com.example.mischedule.alarm_first_action"
intent.putExtra("posit", position);
//intent.putExtra("haha", "haha");
Log.v("verbose", "noticemanager position="+position);//这里打印传入的position确实是点击事件的position
PendingIntent pendingIntent=PendingIntent.getBroadcast(context, 0, intent, 0);
AlarmManager am=(AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
//am.setRepeating(AlarmManager.RTC_WAKEUP,theRightMillis,WEEK_MILLI, pendingIntent);
am.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis()+1000,WEEK_MILLI, pendingIntent);//用来测试,后期可以应该取消
if(intent.getAction()=="com.example.mischedule.alarm_first_action"){
String haha=intent.getStringExtra("haha");
//Log.v("verbose" , "收到的haha="+haha);
int position=intent.getIntExtra("posit", 0);
this.posit=position;
//下面打印得到的position
Log.v("verbose","fist receiver position"+position);