0

i have a rotted Nexus6 With Android6. I've created a system app (located in system/app) i wish to execute a simple code when receiving ACTION_BOOT_COMPLETED but for some reason the code does not executes..

Manifest:

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

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

        <receiver
            android:name="com.atest.testReceiver">
            <intent-filter android:enabled="true">
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Receiver:

public class testReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
            // Some simple code
        }
    }
}

Any suggestions?

EDIT: When executing with adb the following:

am broadcast -a android.intent.action.BOOT_COMPLETED -p com.atest

The code execute as expected, but still when rebooting/booting, no success..

MTZ4
  • 2,274
  • 2
  • 25
  • 41
  • How is it installed in `/system/app`? That's your big clue, your app does not have system level privilege. Install it as normal user instead. – t0mm13b May 02 '16 at 13:28
  • 1. Does your app really installed? Can you see it in app settings page? Try to search logcat information about your package name. 2. Does this code work on device with Android version less than 6? 3. Before installing as system app, try install it as normal app. Now does the code work? – Daniel May 02 '16 at 15:55
  • @t0mm13b i'm not sure i understand what u mean? what is 'normal user'? and why should i'll get the permissions that way? – MTZ4 May 02 '16 at 17:03
  • @Daniel 1. Yes. 2. need to check... 3. I've installed it before as a normal app. i didn't got the boot completed permissions. But i checked the same code for USER_PRESENT action and it worked perfectly. – MTZ4 May 02 '16 at 17:05
  • I am saying, user installed apps do not go into `/system/app` which is system installed applications like google maps etc. All system apps have system privilege and signed by the ROM maker. – t0mm13b May 02 '16 at 17:12
  • 1. Try open app using launcher activity and reboot. Does your code executed? 2. Try put app in /system/app-priv dir – Daniel May 02 '16 at 17:28
  • @t0mm13b i understand, it's not a system app but a priv-app as Daniel suggested. I've moved it to /system/priv-app and still no success. – MTZ4 May 04 '16 at 05:45
  • @Daniel regarding (1), the app has been opened before reboot if that is what you mean. Thank you guys both, do you have any other suggestions? i'm still stuck... – MTZ4 May 04 '16 at 05:45
  • Name of receiver shouldn't be .testReceiver? Why is it com.atest.testReceiver? – Daniel May 04 '16 at 05:57
  • I've tried to change it because f this thrad: http://stackoverflow.com/questions/16691806/android-why-i-am-not-receiving-the-boot-completed-intent But it's the same result neither way – MTZ4 May 04 '16 at 06:00
  • Oh i found something interesting, i'll edit the question maybe it will help to figure this out.. – MTZ4 May 04 '16 at 06:07
  • @Daniel also tried on Android 4.4.2 (also rooted, in priv-app and all). Result is the same.. i guess i'm missing something. Don't know what, probably a really basic one...! – MTZ4 May 04 '16 at 08:59
  • You have looked at [this](http://stackoverflow.com/questions/5051687/broadcastreceiver-not-receiving-boot-completed) Try changing installLocation to internal, or add a category? – t0mm13b May 04 '16 at 15:03
  • Usually you don't need to use. "-p" switch in order to test your receiver. If you omit it, does it work? – Daniel May 04 '16 at 15:58
  • @t0mm13b tried it just now.. no success. – MTZ4 May 05 '16 at 10:21
  • @Daniel without "-p" device will reboot.. – MTZ4 May 05 '16 at 10:22

0 Answers0