Friday, 13 September 2013

Application Kills itself after few hours , Dont want to use startForeground

Application Kills itself after few hours , Dont want to use startForeground

I am using a Service for fetching Coordinates from GPS as well as from
Network
I am Using Alarm Manager to activate the Service every 2 Minute like
Intent myIntent=new Intent(Main.this,ServiceNew.class);
PendingIntent
pendingIntent=PendingIntent.getService(OkayaMain.this,0,myIntent,0);
AlarmManager
alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
Calendar cal=Calendar.getInstance();
cal.add(Calendar.MINUTE,0);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis(),UPDATE_INTERVAL,pendingIntent);
It activates every 2 min But after some time it kill or OS Make it to kill
, I Dont Want to use Foreground Services
my ServiceClass is ServiceNew.class
public class ServiceNew extends Service{
public void onCreate(){
super.onCreate();
try{
fnPushLocationCoordinates();
// This will save the Coordinates after getting through Location MAnager
}
catch(Exception ex){
response=ex.toString();
return;
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//fnPushLocation();
return START_STICKY;
}
@Override
public IBinder onBind(Intent arg0){
return null;
}
I dont want application to be killed , do we have any solution for this
Please Help ,Thanks in advance

No comments:

Post a Comment