如何以编程方式打开并显示手机的消息收件箱..? [英] How to open and show phone's message inbox programmatically..?

查看:89
本文介绍了如何以编程方式打开并显示手机的消息收件箱..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们点击消息,我们都表现出与收件箱。

When we click on messages we are showed with the inbox.

我想表现出同样的窗口,当我点击我的应用程序的按钮。

I want to show the same window when i clicked on my application's button.

所以,我要开始邮件收件箱中的活动。

So, I want to start message inbox activity.

如何做到这一点...?

How to achieve this...?

在此先感谢...!

推荐答案

试试这个......完美的作品..!

Try this.. works perfectly..!

public void openInbox() {
String application_name = "com.android.mms";
try {
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");

intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
List<ResolveInfo> resolveinfo_list = this.getPackageManager()
.queryIntentActivities(intent, 0);

for (ResolveInfo info : resolveinfo_list) {
if (info.activityInfo.packageName
.equalsIgnoreCase(application_name)) {
launchComponent(info.activityInfo.packageName,
info.activityInfo.name);
break;
}
}
} catch (ActivityNotFoundException e) {
Toast.makeText(
this.getApplicationContext(),
"There was a problem loading the application: "
+ application_name, Toast.LENGTH_SHORT).show();
}
}

private void launchComponent(String packageName, String name) {
Intent launch_intent = new Intent("android.intent.action.MAIN");
launch_intent.addCategory("android.intent.category.LAUNCHER");
launch_intent.setComponent(new ComponentName(packageName, name));
launch_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(launch_intent);
}

这篇关于如何以编程方式打开并显示手机的消息收件箱..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆