我使用下面的代码显示默认计算器。但我得到activityNotFound异常。
public static final String CALCULATOR_PACKAGE ="com.android.calculator2";
public static final String CALCULATOR_CLASS ="com.android.calculator2.Calculator";
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName(
CALCULATOR_PACKAGE,
CALCULATOR_CLASS));
try {
startActivity(intent);
} catch (ActivityNotFoundException noSuchActivity) {
// handle exception where calculator intent filter is not registered
}
答案 0 :(得分:0)
这个意图应该让你的工作完成
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_APP_CALCULATOR);
startActivity(i);