Search code examples
androidsmsdefault

How to check whether my SMS app is default in Android


I want to check whether my SMS app is set as default app in android. I am following this tutorial:

http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html

I can set my SMS app as default SMS app by the following code:

Intent intent = new Intent(context, Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Sms.Intents.EXTRA_PACKAGE_NAME, context.getPackageName());
startActivity(intent);

But I want to check whether my SMS app is set as default app. How can I do that?


Solution

  • You can use getDefaultSmsPackage (Context context):

    Used to determine the currently configured default SMS package.

    For example:

    public static boolean isDefaultSmsApp(Context context) {
        return context.getPackageName().equals(Telephony.Sms.getDefaultSmsPackage(context));
    }