I want to run the application immediately after downloading the phone. Apparently, the application starts after loading, but it immediately crashes (just to be clear, the application works fine normally). I already read and tried different solutions ( link1 , link2 ), and actually the same code works fine with the other application that I developed. Here is the code:
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.bluetoothx10y" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="6" android:targetSdkVersion="15" /> <uses-feature android:name="android.hardware.usb.accessory"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <receiver android:name=".StartMyActivityAtBootReceiver" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <activity android:name=".MainActivity" android:label="@string/app_name" android:screenOrientation="landscape" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"/> </intent-filter> <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter"> </meta-data> </activity> <activity android:name=".DeviceListActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Dialog" android:screenOrientation="landscape" /> </application> </manifest>
StartMyActivityAtBootReceiver.java:
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); } } }
Could the fact that I use a lot of user rights be related?
source share