简体   繁体   English

Android- 如何将我的应用程序设为默认短信应用程序?

[英]Android- How can Make my app as Default SMS App?

I am working an SMS Backup app which stores all SIM SMS in an xml file then we can restore back, then proplem is when i want restore it needs to make my APP as Default SMS app , I Have tried all the solutions but didn't worked for me... i used this but all in vain eg: Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);我正在使用SMS 备份应用程序,它将所有SIM短信存储在一个 xml 文件中,然后我们可以恢复,然后问题是当我想要恢复时,它需要将我的应用程序设为默认短信应用程序,我已经尝试了所有解决方案,但没有为我工作......我使用了这个,但都是徒劳的,例如: Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT); intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, myPackageName); intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,myPackageName); startActivity(intent);开始活动(意图);

My App is not showing in Select Default popup .我的应用程序未显示在Select Default popup 中 Please Help.请帮忙。

I tried the following code and its working fine for android 10 and 11我尝试了以下代码,它在 android 10 和 11 上运行良好

make sure to implement all requirements as per this : http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html确保按照此实施所有要求: http : //android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html

and Put following in your Mainactivity class并将以下内容放入您的 Mainactivity 类中

public void perm2(){
        Context mContext3 = getApplicationContext();
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
            RoleManager roleManager = null;
            roleManager = mContext3.getSystemService(RoleManager.class);
            Intent roleRequestIntent = roleManager.createRequestRoleIntent(
                    RoleManager.ROLE_SMS);
            startActivityForResult(roleRequestIntent, MESSAGE_CODE);

        } else {
            Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
            intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,
                    mContext3.getPackageName());
            startActivityForResult(intent, MESSAGE_CODE);
        }

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android - 如何以编程方式使我的应用程序默认短信应用程序 - Android - how to make my app default sms app programatically 如何为我的App android设置默认短信权限? - How can i set default SMS permission to my App android? android-无法使应用程序多语言 - android- can not make the app multi language Android 4.4 SMS:如何通过将我的应用程序设置为默认的短信应用程序将消息插入android 4.4中的SMS提供程序 - Android 4.4 SMS: How to insert message into SMS provider in android 4.4 by setting my app as default sms app 如何在 Android 中取消将我的短信应用设置为默认应用 - How to unset my sms app as default app in Android Android Studio:我的短信应用不是默认短信应用的选项之一 - Android Studio: my sms app is not one of the options for default SMS app Android-是否可以使一个应用程序更改为另一个应用程序? 如果可以,怎么办? - Android- Is it possible to make an app change another app? If so how? 如何检查我的SMS应用程序在Android中是否默认 - How to check whether my SMS app is default in Android 如何在 Android Kitkat 中设置我的短信应用默认设置? - How to set my sms app default in Android Kitkat? 如何执行默认短信应用程序? - How can I execute default sms app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM