Skip to content Skip to sidebar Skip to footer

Intent.category_app_calculator: Activitynotfoundexception

I'm trying to open the default calculator app in a android application. Two calculators are installed in device: default android calculator and Google Calculator. Intent calc = Int

Solution 1:

It seems like the way, that documentation points to doesn't work. Nevertheless, this code will normally open default calculator app.

Intentintent=newIntent();
intent.setClassName("com.android.calculator2", "com.android.calculator2.Calculator");
startActivity(intent);

Solution 2:

The above answer works, but it does not answer the question. The question is how to launch a calculator implicitly via a category. The stock calculator (not the google play version) has the following in the manifest:

<intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /><categoryandroid:name="android.intent.category.APP_CALCULATOR" /></intent-filter>

The problem is simple. If the intent filter is modified as shown below the calculator can be started (tested on Pixel2 running 8.1):

<intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.DEFAULT" /><categoryandroid:name="android.intent.category.LAUNCHER" /><categoryandroid:name="android.intent.category.APP_CALCULATOR" /></intent-filter>

The DEFAULT category is required (and this is clearly documented). The problem is an app that wants to start the activity has no control of the manifest in the target activity.

Post a Comment for "Intent.category_app_calculator: Activitynotfoundexception"