Thursday, August 5, 2010

Starting android calculator programmatically

Here goes:

public static final String CALCULATOR_PACKAGE =
"com.android.calculator2";
public static final String CALCULATOR_CLASS =
"com.android.calculator2.Calculator";

public static void OpenCalculator(Context context) {
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);

i.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(new ComponentName(
CALCULATOR_PACKAGE,
CALCULATOR_CLASS));
context.startActivity(i);
}

No comments: