Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to repeat my service using alarm manager?
    primarykey
    data
    text
    <p>I have done a location based app. Now I need to run my location service once in 30 mins. For that I have tried using alarm manager but it is running my service only once. I need it to run every 30 mins?</p> <p>My code:</p> <p>gps_back_process.java:</p> <pre><code>public class gps_back_process extends Service { private static final String TAG = "MyService"; @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); Log.d("Testing", "Service got created"); Toast.makeText(this, "gps_back_process,onCreate();", Toast.LENGTH_LONG).show(); } @Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } @Override public void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); } @Override public void onStart(Intent intent, int startid) { Intent intents = new Intent(getBaseContext(),gps.class); intents.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intents); Toast.makeText(this, "gps_back_process.onCreate();", Toast.LENGTH_LONG).show(); Log.d(TAG, "onStart"); } } </code></pre> <p>gps.java:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); { Calendar cur_cal = Calendar.getInstance(); cur_cal.setTimeInMillis(System.currentTimeMillis()); cur_cal.add(Calendar.SECOND, 90); Log.d("Testing", "Calender Set time:" + cur_cal.getTime()); Intent intent = new Intent(gps.this, gps_back_process.class); Log.d("Testing", "Intent created"); PendingIntent pi = PendingIntent.getService(gps.this, 0, intent, 0); AlarmManager alarm_manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarm_manager.set(AlarmManager.RTC, cur_cal.getTimeInMillis(), pi); Log.d("Testing", "alarm manager set"); Toast.makeText(this, "gps_back_process.onCreate()", Toast.LENGTH_LONG).show(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload