List of usage examples for android.view.inputmethod InputMethodInfo getId
public String getId()
From source file:Main.java
public static String isVoiceSearchServiceExist(Context context) { if (DEBUG)/*w w w .j ava 2 s. c o m*/ Log.i(TAG, "isVoiceSearchServiceExist()"); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); List<InputMethodInfo> mInputMethodProperties = imm.getEnabledInputMethodList(); //boolean isVoiceSearchServiceEnabled = false; for (int i = 0; i < mInputMethodProperties.size(); i++) { InputMethodInfo imi = mInputMethodProperties.get(i); if (DEBUG) Log.i(TAG, "enabled IM " + i + ":" + imi.getId()); if (imi.getId().equals("com.google.android.voicesearch/.ime.VoiceInputMethodService")) { return "com.google.android.voicesearch/.ime.VoiceInputMethodService"; } else if (imi.getId().equals( "com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService")) { return "com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService"; } } return null; }
From source file:Main.java
/** * Check if the IME specified by the context is the current IME. * CAVEAT: This may cause a round trip IPC. * * @param context package context of the IME to be checked. * @param imm the {@link InputMethodManager}. * @return true if this IME is the current IME. *//*from w ww . j a va2s. c o m*/ public static boolean isThisImeCurrent(final Context context, final InputMethodManager imm) { final InputMethodInfo imi = getInputMethodInfoOf(context.getPackageName(), imm); final String currentImeId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); return imi != null && imi.getId().equals(currentImeId); }
From source file:io.digibyte.tools.util.Utils.java
public static boolean isUsingCustomInputMethod(Activity context) { if (context == null) return false; InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm == null) { return false; }/* w w w . j av a 2s . com*/ List<InputMethodInfo> mInputMethodProperties = imm.getEnabledInputMethodList(); final int N = mInputMethodProperties.size(); for (int i = 0; i < N; i++) { InputMethodInfo imi = mInputMethodProperties.get(i); if (imi.getId().equals(Settings.Secure.getString(context.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD))) { if ((imi.getServiceInfo().applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { return true; } } } return false; }
From source file:net.HeZi.Android.HeInputLibrary.HeInput_Activation_Fragment.java
private void updateUI() { boolean bActivated = false; boolean bDefaultKeyboard = false; boolean bDialectSelected = false; activeHeInputBtn.setEnabled(true);//from ww w. jav a 2 s. co m selectDefaultMethodBtn.setEnabled(false); selectDefaultMethodBtn.setTextColor(Color.GRAY); selectChineseDialectBtn.setEnabled(false); selectChineseDialectBtn.setTextColor(Color.GRAY); //Check Activited //http://stackoverflow.com/questions/4210086/how-can-i-get-a-list-of-all-the-input-methods-and-their-names-that-are-install InputMethodManager imeManager = (InputMethodManager) getActivity().getApplicationContext() .getSystemService(Context.INPUT_METHOD_SERVICE); List<InputMethodInfo> InputMethods = imeManager.getEnabledInputMethodList(); for (InputMethodInfo item : InputMethods) { if (item.getPackageName().toLowerCase().equals(hostApplicationName.toLowerCase())) { bActivated = true; inputId = item.getId(); Log.d("Input Id: ", "InputId: " + inputId); setting_instruction.setText(getString(R.string.instruction_2_steps)); activeHeInputBtn.setEnabled(false); activeHeInputBtn.setTextColor(Color.GRAY); activeHeInputBtn.setText(getString(R.string.heInput_activated)); selectDefaultMethodBtn.setEnabled(true); selectDefaultMethodBtn.setTextColor(Color.RED); selectChineseDialectBtn.setEnabled(false); selectChineseDialectBtn.setTextColor(Color.GRAY); break; } } // Check default keyboard if (bActivated) { String defaultName = Settings.Secure.getString(getActivity().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); if (defaultName.toLowerCase().contains(hostApplicationName.toLowerCase())) { bDefaultKeyboard = true; } } if (bActivated && bDefaultKeyboard) { setting_instruction.setText(getString(R.string.instruction_setting_done)); selectDefaultMethodBtn.setEnabled(false); selectDefaultMethodBtn.setTextColor(Color.GRAY); selectDefaultMethodBtn.setText(getString(R.string.heInput_is_default)); selectChineseDialectBtn.setEnabled(true); selectChineseDialectBtn.setTextColor(Color.RED); editText.setVisibility(View.VISIBLE); editText.requestFocus(); } }