I found almost the same question:How to start an Intent if context is not Activity Context but Application Context
but I faild to do it when using https://stackoverflow.com/a/9238105/6593395
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if ("android.intent.action.BOOT_COMPLETED".equals(action)) {
Intent applicationIntent = new Intent(context, myCamApplication.class);
applicationIntent.setAction(myCamApplication.class.getName());
applicationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(applicationIntent);
the error log:
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.fenchtose.asyncamera/com.eason.mycamera.myCamApplication}; have you declared this activity in your AndroidManifest.xml?
I have registered this myCamApplication class as my application class inside AndroidManifest.xml
<application
android:name=".myCamApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<receiver
android:name=".BootComplete"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name=".myCam"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
So, Anyone could help?