Java tutorial
//package com.java2s; /* * * * * ** Copyright 2015, The LimeIME Open Source Project * ** * ** Project Url: http://github.com/lime-ime/limeime/ * ** http://android.toload.net/ * ** * ** This program is free software: you can redistribute it and/or modify * ** it under the terms of the GNU General Public License as published by * ** the Free Software Foundation, either version 3 of the License, or * ** (at your option) any later version. * * * ** This program is distributed in the hope that it will be useful, * ** but WITHOUT ANY WARRANTY; without even the implied warranty of * ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ** GNU General Public License for more details. * * * ** You should have received a copy of the GNU General Public License * ** along with this program. If not, see <http://www.gnu.org/licenses/>. * * * */ import android.content.Context; import android.util.Log; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import java.util.List; public class Main { static final String TAG = "LIMEUtilities"; static final boolean DEBUG = false; public static String isVoiceSearchServiceExist(Context context) { if (DEBUG) 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; } }