diff options
| author | Yorke Lee <yorkelee@google.com> | 2014-05-18 17:37:32 -0700 |
|---|---|---|
| committer | Yorke Lee <yorkelee@google.com> | 2014-05-18 17:37:32 -0700 |
| commit | 46fd712ad2896858d977274f94a08aef5bdf0e4c (patch) | |
| tree | b1ee32bdccd4d129c486513f3609e6dbebcf6aba /src/com/android/dialer/util | |
| parent | cb782e57c5cb6802584b224911984bddbc85a989 (diff) | |
| download | packages_apps_Dialer-46fd712ad2896858d977274f94a08aef5bdf0e4c.tar.gz packages_apps_Dialer-46fd712ad2896858d977274f94a08aef5bdf0e4c.tar.bz2 packages_apps_Dialer-46fd712ad2896858d977274f94a08aef5bdf0e4c.zip | |
Add send message option to dialpad
Bug: 14052383
Change-Id: I45e9ffc829664af0010eb99be453160bcab2ac3d
Diffstat (limited to 'src/com/android/dialer/util')
| -rw-r--r-- | src/com/android/dialer/util/DialerUtils.java | 28 |
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; + } } |
