だから私はこのサイトから繰り返し機能を実装しようとしています - http://www.java2s.com/Code/Android/Core-Class/Exampleofschedulingoneshotandrepeatingalarms.htm - 私のAndroidアプリにコードの抜粋。
public class MainActivity extends Activity implements SensorEventListener {
// Schedule repeating alarm
Intent intent = new Intent(MainActivity.this, RepeatingAlarm.class);
PendingIntent sender = PendingIntent.getBroadcast(MainActivity.this, 0,
intent, 0);
// We want the alarm to go off 30 seconds from now.
long firstTime = SystemClock.elapsedRealtime();
firstTime += 15 * 1000;
// Schedule the alarm!
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime,
15 * 1000, sender);
// Tell the user about what we did.
Toast.makeText(
getApplicationContext(),
"Scheduled", Toast.LENGTH_LONG)
.show();
}
//Schedule alarm for data upload
class RepeatingAlarm extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(
context,
"ALARMED!", Toast.LENGTH_LONG)
.show();
}
}
それが役立つ場合は、完全なコードがここにあります: https://gist.github.com/4410665