[英]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.