Home > database >  Unable to find explicit activity class {com.android.deskclock/com.android.deskclock.DeskClock}have y
Unable to find explicit activity class {com.android.deskclock/com.android.deskclock.DeskClock}have y

Time:10-17

I'm trying to launch Deskclock app from a different application using below code:

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setComponent(new ComponentName("com.android.deskclock","com.android.deskclock.DeskClock"));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

And I see below error: AndroidRuntime: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.deskclock/com.android.deskclock.DeskClock}; have you declared this activity in your AndroidManifest.xml?

Why should i declare Deskclock activity in my application?

CodePudding user response:

add this activity in your AndroidManifest.xml

CodePudding user response:

add this activity in your AndroidManifest.xml and try once

<manifest> 
    <queries>
        <package android:name="com.android.deskclock" />
    </queries>
    ...
</manifest>
  • Related