我怎么能拿的默认短信应用的包叫什么名字? [英] how could I get default sms app's package name?

查看:717
本文介绍了我怎么能拿的默认短信应用的包叫什么名字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为默认的短信应用在4.4加,我无法打开默认的短信应用是这样的:

As default sms app is added in 4.4, I cannot open default sms app like this:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);

所以,我怎么能得到的默认短信应用的软件包名称,这样我就可以直接从我的应用程序打开它?

So how could I get default sms app's package name, so I can open it from my app directly?

推荐答案

// <一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.4.4_r1/android/provider/Settings.java#Settings.Secure.0SMS_DEFAULT_APPLICATION\" rel=\"nofollow\">http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.4.4_r1/android/provider/Settings.java#Settings.Secure.0SMS_DEFAULT_APPLICATION

公共静态最后弦乐SMS_DEFAULT_APPLICATION =sms_default_application;

public static final String SMS_DEFAULT_APPLICATION = "sms_default_application";

<一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.4.4_r1/com/android/internal/telephony/SmsApplication.java#267\" rel=\"nofollow\">http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.4.4_r1/com/android/internal/telephony/SmsApplication.java#267

if(Utils.hasKikKat()) {
    String defaultApplication = Settings.Secure.getString(getContentResolver(),  SMS_DEFAULT_APPLICATION);
    PackageManager pm = context.getPackageManager();
    Intent intent = pm.getLaunchIntentForPackage(defaultApplication );
      if (intent != null) {
        context.startActivity(intent);
      }
} else {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setType("vnd.android-dir/mms-sms");
    startActivity(intent);
}

这篇关于我怎么能拿的默认短信应用的包叫什么名字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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