jeudi 27 mars 2014

Declare a service in AndroidManifest.xml and prevent it from starting alone


Vote count:

0





<service
android:name="com.mypackage.android.AutoUpdateService"
android:process=":update"
android:exported="false">
<intent-filter>
<action android:name="com.mypackage.android.UPDATE" />
</intent-filter>
</service>


I am creating a service which performs an update. It runs on its own thread and isn't exported because I don't really need other applications to access it. (Not that relevant but for those who want to know ..) My problem is I can't manage to prevent it from starting on its own. How do I declare my service and start it on my own?


Here is how I start the service in case you want to know



Calendar Cal = Calendar.getInstance();

Intent UpdateServiceIntent = new Intent(this, AutoUpdateService.class);
PendingIntent PendingItent = PendingIntent.getService(this, 999, UpdateServiceIntent, 0);

AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC, Cal.getTimeInMillis(), 1000, PendingItent);


asked 39 secs ago






Aucun commentaire:

Enregistrer un commentaire