TransWikia.com

How to listen to Boot Complete broadcast in Oneplus?

Stack Overflow Asked by Saarang Tiwari on March 8, 2021

I am working on an android application that listens to Boot Complete Broadcast and performs some processes.
This broadcast works on my Moto G5 and simulator, however, on Oneplus the application never receives it.

One Answer

Create a BroadCastReciver class like this :

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class RebootService extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

        Toast.makeText(context,"Service is running", Toast.LENGTH_LONG).show();

    }
}

Define your service in AndroidManifest.

<receiver android:name=".RebootService">

    <intent-filter>


        <action android:name="android.intent.action.BOOT_COMPLETED"/>

    </intent-filter>

</receiver>

And finally :

   <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

Answered by Farzad Sarseify on March 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP