Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Tutorial: <br> <a href="http://red-folder.blogspot.com/2012/09/phonegap-android-background-service.html" rel="nofollow">http://red-folder.blogspot.com/2012/09/phonegap-android-background-service.html</a></p> <p>I think you must write a service(java) in android, it very easy, and simply. <code></p> <pre><code>@Override public void onCreate() { Calendar cal = Calendar.getInstance(); Intent intent = new Intent(this, MyService.class); PendingIntent pintent = PendingIntent.getService(this, 0, intent, 0); AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE); alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 60*1000, pintent); } @Override public int onStartCommand(Intent intent, int flags, int startId) { if(isOnline()) text="Network available."; else text="Network not available."; showNotification(text); return START_STICKY; } @Override public void onDestroy() { } @Override public IBinder onBind(Intent intent) { return null; } @SuppressWarnings("deprecation") void showNotification(String text){ mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); notification = new Notification(R.drawable.ic_launcher, text,System.currentTimeMillis()); notification.flags |= Notification.FLAG_AUTO_CANCEL; //notification.flags |= Notification.DEFAULT_SOUND; //resultIntent = getPackageManager().getLaunchIntentForPackage("com.example.hello"); resultIntent = new Intent( this , MainActivity.class ); contentIntent = PendingIntent.getActivity( this, 0,resultIntent, 0 ); notification.setLatestEventInfo( this, "Internet", text , contentIntent ); mNM.notify(1, notification); } public boolean isOnline() { connMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); networkInfo = connMgr.getActiveNetworkInfo(); return (networkInfo != null &amp;&amp; networkInfo.isConnected()); } </code></pre> <p></code></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.
    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