2012-01-24 17 views
0

海はすべてのボディは親切方法Androidアプリケーションで10分ごとにアラームを設定するにはどうすればよいですか?

をalarmManager.setRepeating私

Intent intent = new Intent(this, ConnectionReceiver.class); 

PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, 
intent, PendingIntent.FLAG_ONE_SHOT); 

AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); 
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1 * 1000), pendingIntent); 
Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();//every 10 minutes i want to print the toast 
+0

(1 * 1000)を(10 * 60 * 1000)で置き換えます。ここでは、あなたのコードでalarmManagerを設定します。 – Hiral

答えて

2
Calendar calCurrent = Calendar.getInstance(); 
    long tenmin = 10 * 60 * 1000; 
    int mynotifyidis = Integer.parseInt(mydelid); 
    Intent mIntent = new Intent(this, NotificationService1.class); 
    mIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    mIntent.putExtra("id", mynotifyidis); 

    AlarmManager mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); 
    PendingIntent snoozependingintent = PendingIntent.getService(this, 
      -mynotifyidis, mIntent, PendingIntent.FLAG_ONE_SHOT); 

    mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 
      calCurrent.getTimeInMillis() + fivemin, fivemin, 
      snoozependingintent); 
関連する問題