این کدهای من هستش : کدهای بخش ریستارت شدن سرویس
@Override
public void onTaskRemoved(Intent rootIntent){
Log.i("service","service are killed");
sendBroadcast(new Intent("YouWillNeverKillMe"));
Intent restartServiceIntent = new Intent(this, this.getClass());
restartServiceIntent.setPackage(getPackageName());
PendingIntent restartServicePendingIntent = PendingIntent.getService(G.context, 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmService = (AlarmManager) G.context.getSystemService(G.context.ALARM_SERVICE);
alarmService.set(
AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime() +3000,
restartServicePendingIntent);
super.onTaskRemoved(rootIntent);
}
@Override
public void onDestroy() {
super.onDestroy();
sendBroadcast(new Intent("YouWillNeverKillMe"));
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, final int startId) {
if (getNotic == null) {
getNotic=new Timer();
getNotic.schedule(new TimerTask() {
@Override
public void run() {
get_notic();
}
},10*60*1000,10*60*1000);
}
return START_STICKY;
}
اینم هم برود کست
public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("service", "onReceive");
context.startService(new Intent(G.context, backDoor.class));
}
}
این هم کدهای فایل منیفست
<service android:name=".backDoor"
android:process=":remote" >
</service>
<receiver android:name="com.oneremind.oneremind.MyBroadcastReceiver">
<intent-filter>
<action android:name="YouWillNeverKillMe" >
</action>
</intent-filter>
</receiver>