How (i.e., what intent action) to start the set up email account activity (add new email account activity) of the email application

╄→гoц情女王★ 提交于 2019-12-08 10:26:29

问题


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


回答1:


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.




回答2:


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);


来源:https://stackoverflow.com/questions/12765048/how-i-e-what-intent-action-to-start-the-set-up-email-account-activity-add-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!