Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class I3 extends Service {
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
- @Override
- public void onCreate() {
- super.onCreate();
- }
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- ...
- return START_STICKY;
- }
- @Override
- public void onDestroy() {
- super.onDestroy();
- sendBroadcast(new Intent("com.mypackage.Restart"));
- }
- ...
- }
- public class I2 extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- context.startService(new Intent(context, I3.class));
- }
- }
- ...
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
- ...
- <uses-sdk
- android:minSdkVersion="15"
- android:targetSdkVersion="25" />
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@android:style/Theme.NoTitleBar" >
- <activity
- android:name=".I1"
- android:label="@string/app_name"
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <receiver
- android:name=".I2"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- <intent-filter>
- <action android:name="com.mypackage.Restart" />
- </intent-filter>
- </receiver>
- <service
- android:name=".I3"
- android:label="@string/app_name" />
- </application>
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement