BOOT COMPLETE is not working in Android (Redmi)
Asked Answered
O

4

2

I am currently working on a application which includes Boot_Completed Broadcast receiver concept. I have tested this app in my Motorola Moto G Phone. The app runs fine and shows the Toast message. But when I test this app in XIAOMI Redmi 1S phone it doesn't show the Toast message.

I have already seen many questions similar to my issue (like these - Question 1, Question 2, etc.) ... But I haven't got any solution to this problem.

My Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demoapp"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="internalOnly" >
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.demoapp.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="com.example.demoapp.MyReceiver"
        android:enabled="true"
        android:exported="true" >
        <intent-filter >
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
        </intent-filter>
    </receiver>
 </application>
 </manifest>

MyReceiver.java

public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    if ("android.intent.action.BOOT_COMPLETED".equalsIgnoreCase(intent.getAction())) {
        Toast.makeText(context, "Boot Complete.", Toast.LENGTH_LONG).show();
    }
}
}

How can I solve this?

Ongoing answered 6/1, 2015 at 5:32 Comment(5)
what is your PACKAGE_NAME?? and source MyReceiver package names??Lebeau
"com.example.demoapp" is my PACKAGE_NAME. @kalyanpvsOngoing
Facing same issue with Xiaomi Redmi 1s.Funky
then change it in manifest like package="com.example.demoapp" and is Myreceiver is class path is "com.example.demoapp.MyReceiver"??Lebeau
I change this but not worked. @kalyanpvsOngoing
B
6

This is solution for your bug.

What you need to do is that , you need to mention this permission also in your Intent-Filter.

               <receiver android:name="com.example.demoapp.MyReceiver"
                         android:enabled="true"
                         android:exported="true" >

               <intent-filter >
                       <action android:name="android.intent.action.BOOT_COMPLETED"/>
                       <action android:name="android.intent.action.REBOOT"/>
               </intent-filter>
               </receiver>

Here you need to do one thing also.

Go to "Settings-Apps_open your app info-Manage permisson" in yourdevice

Here check all things here.

Because for some devices it will not work. Ex.Red mi

Try this !

Benzyl answered 6/1, 2015 at 6:50 Comment(3)
This worked as a solution to my Redmi 1s problem. Thanks Jay for the info.Conferral
Adding <action android:name="android.intent.action.REBOOT"/> didn`t helpl me with Redmi 1s. It only worked after a added my app in the Auto-Restart app list in the Security App provided by the MIUI.Greige
Its not working in my Xiaomi Note 10 liteAlphonse
F
7

in case of XIOMI devices you have to manually set permission, i think you can solve this by adding your app in "auto-start management" list, which is available as default security app.

Fults answered 6/1, 2015 at 5:55 Comment(1)
How to add my app in "auto-start management" list? @user3188965Ongoing
B
6

This is solution for your bug.

What you need to do is that , you need to mention this permission also in your Intent-Filter.

               <receiver android:name="com.example.demoapp.MyReceiver"
                         android:enabled="true"
                         android:exported="true" >

               <intent-filter >
                       <action android:name="android.intent.action.BOOT_COMPLETED"/>
                       <action android:name="android.intent.action.REBOOT"/>
               </intent-filter>
               </receiver>

Here you need to do one thing also.

Go to "Settings-Apps_open your app info-Manage permisson" in yourdevice

Here check all things here.

Because for some devices it will not work. Ex.Red mi

Try this !

Benzyl answered 6/1, 2015 at 6:50 Comment(3)
This worked as a solution to my Redmi 1s problem. Thanks Jay for the info.Conferral
Adding <action android:name="android.intent.action.REBOOT"/> didn`t helpl me with Redmi 1s. It only worked after a added my app in the Auto-Restart app list in the Security App provided by the MIUI.Greige
Its not working in my Xiaomi Note 10 liteAlphonse
S
2

Go to manage app permission

Select your app from apps

toggle "Auto-Start"

done

Stayathome answered 6/1, 2015 at 6:16 Comment(0)
B
1

try removing if condition from broadcast reciever

public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    Toast.makeText(context, "Boot Complete.", Toast.LENGTH_LONG).show();
}
}
Biofeedback answered 6/1, 2015 at 6:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.