summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/util/DialerUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/dialer/util/DialerUtils.java')
-rw-r--r--src/com/android/dialer/util/DialerUtils.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/com/android/dialer/util/DialerUtils.java b/src/com/android/dialer/util/DialerUtils.java
index 8b0c4c6dd..584caa9a1 100644
--- a/src/com/android/dialer/util/DialerUtils.java
+++ b/src/com/android/dialer/util/DialerUtils.java
@@ -16,12 +16,20 @@
package com.android.dialer.util;
import android.content.ActivityNotFoundException;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
+import android.provider.Telephony;
import android.widget.Toast;
+import com.android.contacts.common.CallUtil;
import com.android.dialer.R;
+import java.util.List;
+
/**
* General purpose utility methods for the Dialer.
*/
@@ -54,4 +62,24 @@ public class DialerUtils {
Toast.makeText(context, msgId, Toast.LENGTH_SHORT).show();
}
}
+
+ /**
+ * Returns the component name to use in order to send an SMS using the default SMS application,
+ * or null if none exists.
+ */
+ public static ComponentName getSmsComponent(Context context) {
+ String smsPackage = Telephony.Sms.getDefaultSmsPackage(context);
+ if (smsPackage != null) {
+ final PackageManager packageManager = context.getPackageManager();
+ final Intent intent = new Intent(Intent.ACTION_SENDTO,
+ Uri.fromParts(CallUtil.SCHEME_SMSTO, "", null));
+ final List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, 0);
+ for (ResolveInfo resolveInfo : resolveInfos) {
+ if (smsPackage.equals(resolveInfo.activityInfo.packageName)) {
+ return new ComponentName(smsPackage, resolveInfo.activityInfo.name);
+ }
+ }
+ }
+ return null;
+ }
}