Accessing Android Inbox/Messaging from Activity?

喜夏-厌秋 提交于 2019-12-01 12:33:06

问题


Is it possible to open up the default Android Messaging activity from inside an activity you write yourself? Like for example: I press a "Mail" button inside my program, and it opens the Android Messaging app just like as if I was to press the Messaging icon on the main screen.

I did something similar to this with the Contacts activity, but only the contact list comes up, no extra functionality like Adding/Modifying/Deleting, etc.

Any ideas?

edit: I found this way to open the "Compose New Message" Activity, I just need to back it up a step. Does anyone know the correct MIME type instead of this one?

Intent sendIntent = new Intent(Intent.ACTION_VIEW); 
sendIntent.setType("vnd.android-dir/mms-sms"); 
m_activity.startActivity(sendIntent); 

回答1:


This starts the messaging app from another app:

Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(new ComponentName("com.android.mms","com.android.mms.ui.ConversationList"));
startActivity(intent);

Just put it inside a button listener or whatever user input you want to open it from.

Enjoy :-)




回答2:


If you want to open the messaging app to view messages and not for sending a message, this should do the job:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setPackage("com.google.android.apps.messaging");
startActivity(intent);


来源:https://stackoverflow.com/questions/3260471/accessing-android-inbox-messaging-from-activity

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