aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Utils.java
diff options
context:
space:
mode:
authorSatoshi Kataoka <satok@google.com>2013-03-22 14:53:03 +0900
committerSatoshi Kataoka <satok@google.com>2013-03-22 16:19:44 +0900
commit3c8117c88fc738f841ac43f5a88602a99b901fee (patch)
tree150e3ddd7b454f78cb1d81e50c0713a91368abd1 /java/src/com/android/inputmethod/latin/Utils.java
parentc6452f2569448aee841ad70baaa27c660a753aff (diff)
downloadlatinime-3c8117c88fc738f841ac43f5a88602a99b901fee.tar.gz
latinime-3c8117c88fc738f841ac43f5a88602a99b901fee.tar.xz
latinime-3c8117c88fc738f841ac43f5a88602a99b901fee.zip
Fix appname
Bug: 6789579 Change-Id: Ic4694e36e0846af95fa8dcdef919be251983b528
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Utils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index 7a604dc6a..aff5d17d7 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -16,8 +16,13 @@
package com.android.inputmethod.latin;
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.inputmethodservice.InputMethodService;
import android.net.Uri;
import android.os.AsyncTask;
@@ -45,6 +50,8 @@ import java.util.Date;
import java.util.Locale;
public final class Utils {
+ private static final String TAG = Utils.class.getSimpleName();
+
private Utils() {
// This utility class is not publicly instantiable.
}
@@ -453,4 +460,17 @@ public final class Utils {
if (TextUtils.isEmpty(info)) return null;
return info;
}
+
+ public static int getAcitivityTitleResId(Context context, Class<? extends Activity> cls) {
+ final ComponentName cn = new ComponentName(context, cls);
+ try {
+ final ActivityInfo ai = context.getPackageManager().getActivityInfo(cn, 0);
+ if (ai != null) {
+ return ai.labelRes;
+ }
+ } catch (NameNotFoundException e) {
+ Log.e(TAG, "Failed to get settings activity title res id.", e);
+ }
+ return 0;
+ }
}