0

I have trying to implement a receiver which will work on startup, in my application. for that I have created a MyReceiver class and then added that in my manifest. am also added the permission too. But its not working and also not showing in the app info.

here is my manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.inapp.sampleboot" >

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

    <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=".MyReceiver"
            >
            <intent-filter>
                <action android:name="ANDROID.INTENT.ACTION.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

My reciever class

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

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

    }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
ranjith
  • 4,526
  • 5
  • 27
  • 31

3 Answers3

0

I thinks this will be a solution

<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE" />

Android is case-sensitive in most places. Please change this to:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
ranjith
  • 4,526
  • 5
  • 27
  • 31
0

There are two actions in your receiver intent filter. That's the problem. Instead have two intent filter for the receiver.

Something like this perhaps:

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

Do you really need the second action ?

Go through this if you face any other issue on this topic: https://stackoverflow.com/a/26026471/4747587

Community
  • 1
  • 1
Henry
  • 17,490
  • 7
  • 63
  • 98
0

launch your application at least once after installation, then reboot your device. hope it will work

rajeev kumar
  • 239
  • 1
  • 4
  • 11