How to find default sms messaging app

From api level 19 onwards, its just a one line call to get the packageName of default sms application.
Before API level 19, there is no concept of Default Sms, so what we can do is get the list of messaging apps.
private Object[] getMessagingAppPackageNames(Context context) {
   List messagingAppPackgeNameList = new ArrayList<>();
   final PackageManager pm = context.getPackageManager();
   //get metaData for installed apps
   List packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

   for (ApplicationInfo appInfo : packages) {
      String packageName = appInfo.packageName;
      if (packageName != null && (packageName.contains("sms")
             || packageName.contains("mms") || packageName.contains("message")
             || packageName.contains("SMS") || packageName.contains("MMS")
             || packageName.contains("Message") || packageName.contains("media")
             || packageName.contains("Media"))) {
   return messagingAppPackgeNameList.toArray();
This list may have all messaging apps plus some other apps also. But at least we can make sure the list will have all messaging app package names.


Popular posts from this blog

Open Gallery and get the selected image in appplication

AlarmManager and Notification in Android

Dismiss or Cancel dialog by swipe gesture