How (i.e., what intent action) to start the set up

2019-06-13 02:05发布

From within my app, I'd like to start the set up new email account activity of the Email App which looks like this: http://i.stack.imgur.com/BNYnj.png

I've looked at this http://source-android.frandroid.com/packages/apps/Email/AndroidManifest.xml

and tried to start the set up email activity:

Intent intent = new Intent("com.android.email.CREATE_ACCOUNT");
startActivity(intent);

But I got an exception: E/AndroidRuntime(517): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.email.CREATE_ACCOUNT }

Anyone please help me?

Thanks so much, John

2条回答
Summer. ? 凉城
2楼-- · 2019-06-13 02:57

you could try using an explicit intent. instead of

new Intent("com.android.email.CREATE_ACCOUNT")

use

new Intent(context, com.android.email.activity.setup.AccountSetupBasics.class)

you may also want to look into the whole ACTION_ADD_ACCOUNT action string. it may do what you are looking for without having to use a SPECIFIC app. for example, when an oem installs a different email app from the stock android one. if it happens there won't be anything to handle either the explicity or implicit intent.

查看更多
Animai°情兽
3楼-- · 2019-06-13 03:05

This works for from APIs 4.0+.

Intent intent = new Intent("com.android.email.CREATE_ACCOUNT");
intent.putExtra("FLOW_MODE", 0);
startActivity(intent);

Below works for from APIs 2.1+. Maybe also work for lower versions (not tested).

Intent intent = new Intent();
intent.setClassName("com.android.email", "com.android.email.activity.setup.AccountSetupBasics");
intent.putExtra("FLOW_MODE", 0);
startActivity(intent);
查看更多
登录 后发表回答