您可以使用AlaramManager設置何時調用活動的時間。
Intent intentA=new Intent(context, A.class);
pendingIntent=PendingIntent.getBroadcast(this, 0, intentA, 0);
alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,0,3000, pendingIntent);
Intent intentB=new Intent(context, B.class);
pendingIntent=PendingIntent.getBroadcast(this, 0, intentB, 0);
alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,1000,3000, pendingIntent);
Intent intentC=new Intent(context, C.class);
pendingIntent=PendingIntent.getBroadcast(this, 0, intentC, 0);
alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,2000,3000, pendingIntent);
我還沒有嘗試過,但我認爲它會做很少的修改。
只需使用計時器? – 2013-05-01 07:13:27
你有一些在Android C#中使用Timer的例子嗎? – lukso 2013-05-01 07:40:25
使用處理程序,你可以做到這一點,但在覈心機器人。 – 2013-05-01 07:46:21