1

I am receiving Network change event on my broadcast receiver when my App is active but once I reboot the phone (Oppo phone 4.4.2 version), my App does not receive any of those events - Network change, Boot completed.

Have been struggling for a day now, your help is highly appreciated.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.testbootcompleted"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="12"
        android:targetSdkVersion="23" />

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="com.sarkms.cclib.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <receiver
            android:name="com.example.testbootcompleted.BootUpReceiver"
            android:enabled="true"
            android:exported="true" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.example.testbootcompleted.NetworkChangeReceiver"
            android:enabled="true"
            android:exported="true" >
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" >
                    <action android:name="android.net.wifi.WIFI_STATE_CHANGED" >
                    </action>
                </action>
            </intent-filter>
        </receiver>        

        <activity android:name="com.example.testbootcompleted.MainActivity"
            android:label="@string/title_activity_main"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
Krishnan V S
  • 1,124
  • 1
  • 13
  • 31
  • see this [http://stackoverflow.com/questions/14385231/android-broadcastreceiver-auto-run-service-after-reboot-of-device][1] – Nayra Ahmed Feb 21 '16 at 12:14
  • Thanks, I missed out mentioning that I have already set the usual permissions. It is working fine on my Samsung Note 2 as well as Moto 2G but is not working on my friend's Oppo R827 phone. – Krishnan V S Feb 21 '16 at 12:18
  • Is your problem specific to this model of the android device or any android device? If it is a generic problem I'd suggest you remove the model name and make the question more generic. – Sajib Acharya Feb 21 '16 at 12:18
  • It seems to be specific to this phone. My app is working on other 10-12 devices, but not in this phone. I am launching a product and so need to ensure it is working on most popular brands. – Krishnan V S Feb 21 '16 at 12:24
  • Did you run your activity on this device? – CommonsWare Feb 21 '16 at 12:40
  • Yes I did. When I run the activity, the toast is shown on change of network status. But if I reboot the phone and change network status, the toast is not shown. – Krishnan V S Feb 21 '16 at 12:48

1 Answers1

2

It turned out to be simple - my app had to be added to Auto Run list in the phone's Security Center. Once added, my app received BOOT_COMPLETED and other events.

Krishnan V S
  • 1,124
  • 1
  • 13
  • 31