Note that there are some explanatory texts on larger screens.

plurals
  1. POAlarmManager won't start service
    primarykey
    data
    text
    <p>I just followed the exact code in API Demo, but my service just won't start after I set the AlarmManager.</p> <p>so my service is</p> <pre><code>public class CourseWatcherRefreshService extends Service { private CourseDbAdapter mDbHelper; private CourseWatcher watcher; @Override public void onCreate() { Toast.makeText(this, "Watcher Refresh Service starts", Toast.LENGTH_SHORT).show(); mDbHelper = new CourseDbAdapter(this); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mDbHelper.open(); Thread thread = new Thread(null, mTast, "CourseWatcherRefreshService"); thread.start(); super.onCreate(); } @Override public void onDestroy() { mDbHelper.close(); super.onDestroy(); } Runnable mTast = new Runnable() { // some work }; @Override public IBinder onBind(Intent intent) { return mBinder; } private final IBinder mBinder = new Binder() { @Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { return super.onTransact(code, data, reply, flags); } }; } </code></pre> <p>Also in my AndroidManifest.xml, I put such code</p> <pre><code>&lt;service android:name=".CourseWatcherRefreshService" android:process=":remote" &gt; &lt;/service&gt; </code></pre> <p>And I use such code to toggle the AlarmManager</p> <pre><code>PendingIntent refreshIntent = PendingIntent.getActivity(NaviScreen.this, 0, new Intent(NaviScreen.this, CourseWatcherRefreshService.class), 0); long firstTime = SystemClock.elapsedRealtime(); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, 30*1000, refreshIntent); </code></pre> <p>And the code above is almost the same with the AlartService example in API Demo, but my code won't work, I can't see any sign of my service starts to work.</p>
    singulars
    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.
    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