How to open the default mail inbox from android code?

前端 未结 9 1990
执念已碎
执念已碎 2021-02-19 00:43

I\'m trying to link a button to the mail app. Not to send mail, but just to open the inbox.

Should I do this with Intent intent = new Intent(...)?

9条回答
  •  被撕碎了的回忆
    2021-02-19 00:48

    If the goal is to open the default email app to view the inbox, then key is to add an intent category and use the ACTION_MAIN intent like so:

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_APP_EMAIL);
    getActivity().startActivity(intent);
    

    https://developer.android.com/reference/android/content/Intent.html#CATEGORY_APP_EMAIL

提交回复
热议问题