Note that there are some explanatory texts on larger screens.

plurals
  1. POStart activity on boot
    primarykey
    data
    text
    <p>I'd like to start my app just after the phone boot. Apparently the app is started after the boot but it immediately crashes (just to be clear the app normally works fine). I have already read and tried different solutions (<a href="https://stackoverflow.com/questions/10853879/start-an-activity-on-phone-boot-in-android">link1</a>, <a href="https://stackoverflow.com/questions/14476335/application-is-not-starting-on-device-boot">link2</a>) and actually the same code works fine with another app I was developing. Here's the code:</p> <p>AndroidManifest.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.bluetoothx10y" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="6" android:targetSdkVersion="15" /&gt; &lt;uses-feature android:name="android.hardware.usb.accessory"/&gt; &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt; &lt;uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.BLUETOOTH"/&gt; &lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/&gt; &lt;uses-permission android:name="android.permission.DISABLE_KEYGUARD"/&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;receiver android:name=".StartMyActivityAtBootReceiver" android:enabled="true" android:exported="true"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;activity android:name=".MainActivity" android:label="@string/app_name" android:screenOrientation="landscape" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"/&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter"&gt; &lt;/meta-data&gt; &lt;/activity&gt; &lt;activity android:name=".DeviceListActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Dialog" android:screenOrientation="landscape" /&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>StartMyActivityAtBootReceiver.java:</p> <pre><code> public class StartMyActivityAtBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { Intent myStarterIntent = new Intent(context, MainActivity.class); myStarterIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(myStarterIntent); } } } </code></pre> <p>Could it be related the fact that I'm using the a lot of user permissions? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload