简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM