AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="id.oddsaydev.background_tasks" > <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name=".DeviceBootReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.HOME" /> </intent-filter> </receiver> </application> </manifest>
DeviceBootReceiver.java
import android.app.AlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class DeviceBootReceiver extends BroadcastReceiver { private PendingIntent pendingIntent; private AlarmManager manager; @Override public void onReceive(Context arg0, Intent arg1) { ; Toast.makeText(arg0, "Booting Completed Booting Completed Booting Completed Booting Completed Booting Completed ", Toast.LENGTH_SHORT).show(); } }
0 komentar:
Post a Comment