-1

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 e.g: Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT); intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, myPackageName); startActivity(intent);

My App is not showing in Select Default popup. Please Help.

Bilal Awan
  • 1
  • 1
  • 2
  • You need to satisfy all requirements in your manifest, otherwise your app will not be eligible to become default SMS app. See https://stackoverflow.com/questions/30127564/how-do-i-set-my-app-as-the-default-sms-app – Pawel Nov 03 '20 at 13:17
  • Thanks a lot. it solved... i was mising .MmsReceiver – Bilal Awan Nov 04 '20 at 04:58

1 Answers1

0

I tried the following code and its working fine for android 10 and 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

and Put following in your Mainactivity class

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);
        }

    }

247365 nyy
  • 33
  • 6