I registered my broadcast receiver, like this one (below) in the manifest file. his work fine.
<receiver android:name="MyIntentReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.HOME" /> </intent-filter> </receiver>
But he remains registered. Those. whenever the phone boots up, my application launches. But I want only once.
I realized that if it is registered dynamically, we can achieve this. that is, we can cancel it in the onPause () or onDestroy () method. If possible, please give me the code for this. I am new to this. Any help would be greatly appreciated. Thanks.
I tried the following code, but it was useless:
public class BeforeReboot extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.beforereboot); } private BroadcastReceiver myBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Intent startupBootIntent = new Intent(context, AfterRebootDynamic.class);
source share