Saturday, July 11, 2015

android: Keep running service in background in My application

Add this in manifest

<service    android:enabled="true"  
  android:name=".service_ReloadSqlDB"  
  android:label="check database Update" />



Create your service like this
public class service_ReloadSqlDB extends Service {
Timer timer; B2MDatabaseHelper databaseHelper;
@Override public IBinder onBind(Intent intent) {
return null; }
@Override public void onCreate() {
super.onCreate(); databaseHelper = new B2MDatabaseHelper(getApplicationContext()); }
@Override public void onDestroy() {
super.onDestroy(); }
@Override public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY; }
}


Your service running in background , please your requirement what you want to do in  
Service. 


No comments:

Post a Comment