Example usage for android.content Context INPUT_METHOD_SERVICE

List of usage examples for android.content Context INPUT_METHOD_SERVICE

Introduction

In this page you can find the example usage for android.content Context INPUT_METHOD_SERVICE.

Prototype

String INPUT_METHOD_SERVICE

To view the source code for android.content Context INPUT_METHOD_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.inputmethod.InputMethodManager for accessing input methods.

Usage

From source file:Main.java

public static String isVoiceSearchServiceExist(Context context) {
    if (DEBUG)//from   w  w  w  .j  a  va2  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:org.kepennar.android.client.social.twitter.TwitterTweetActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.twitter_tweet_activity_layout);

    _twitterApi = getApplicationContext().getConnectionRepository().findPrimaryConnectionToApi(TwitterApi.class)
            .getApi();//from   ww w  .  ja  va 2  s  .c o m

    // Initiate the POST request when the button is clicked
    final Button button = (Button) findViewById(R.id.button_tweet);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // hide the soft keypad
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            EditText editText = (EditText) findViewById(R.id.edit_text_tweet);
            inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);

            // start asynchronous twitter post 
            new PostTweetTask().execute();
        }
    });
}

From source file:org.kepennar.android.client.social.twitter.TwitterDirectMessageActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.twitter_direct_message_activity_layout);

    _twitterApi = getApplicationContext().getConnectionRepository().findPrimaryConnectionToApi(TwitterApi.class)
            .getApi();//from w w  w .  j  a  va 2  s.  c o  m

    // Initiate the POST request when the button is clicked
    final Button button = (Button) findViewById(R.id.button_tweet);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // hide the soft keypad
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            EditText editText = (EditText) findViewById(R.id.edit_text_message);
            inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);

            new PostDirectMessageTask().execute();
        }
    });
}

From source file:edu.rowan.app.fragments.FoodCommentFragment.java

public void onStart() {
    super.onStart();
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
}

From source file:com.facebook.android.FQLQuery.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.fql_query);//from   ww w  .ja v  a 2  s  . c  om
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mFQLQuery = (EditText) findViewById(R.id.fqlquery);
    mFQLOutput = (TextView) findViewById(R.id.fqlOutput);
    mSubmitButton = (Button) findViewById(R.id.submit_button);

    mSubmitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(mFQLQuery.getWindowToken(), 0);
            dialog = ProgressDialog.show(FQLQuery.this.activity, "",
                    FQLQuery.this.activity.getString(R.string.please_wait), true, true);
            /*
             * Source tag: fql_query_tag
             */
            String query = mFQLQuery.getText().toString();
            Bundle params = new Bundle();
            params.putString("method", "fql.query");
            params.putString("query", query);
            Utility.mAsyncRunner.request(null, params, new FQLRequestListener());
        }
    });
}

From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java

public filter_dialog(Context cx, List<NameValuePair> data) {
    super(cx);/*  w w  w.j ava  2 s.  c  o  m*/
    this.cx = cx;
    this.webData = data;
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    vocl = new View.OnClickListener() {
        public void onClick(View v) {
            onCheckboxClick(v);
        }
    };

    maxLines = new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView tv, int action, KeyEvent key) {
            boolean handled = false;
            if (action == EditorInfo.IME_ACTION_DONE) {
                setMaxLines(tv.getText().toString());
                tv.setText(getNamedData("iPage"));
                InputMethodManager imm = (InputMethodManager) tv.getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(tv.getWindowToken(), 0);
                handled = true;
            }
            return handled;
        }
    };
    rateListener = new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            rateSelected((String) parent.getItemAtPosition(pos));
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    };
    licenseListener = new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            licenseSelected((String) parent.getItemAtPosition(pos));
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    };
    placementListener = new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            placementSelected((String) parent.getItemAtPosition(pos));
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    };

}

From source file:com.wenwen.chatuidemo.activity.AddContactActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_add_contact);

    editText = (EditText) findViewById(R.id.edit_note);
    searchedUserLayout = (LinearLayout) findViewById(R.id.ll_user);
    nameText = (TextView) findViewById(R.id.name);
    searchBtn = (Button) findViewById(R.id.search);
    avatar = (ImageView) findViewById(R.id.avatar);
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}

From source file:com.ccxt.whl.activity.AddContactActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_contact);

    editText = (EditText) findViewById(R.id.edit_note);
    searchedUserLayout = (LinearLayout) findViewById(R.id.ll_user);
    nameText = (TextView) findViewById(R.id.name);
    searchBtn = (Button) findViewById(R.id.search);
    avatar = (ImageView) findViewById(R.id.avatar);
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    /*************************http?***********************/
    responseHandler = new BaseJsonHttpResponseHandler() {

        @Override//from  w  w  w. j  av  a2s . com
        public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, Object response) {
            // TODO Auto-generated method stub 
            Log.d("setting_qes" + rawJsonResponse);
            progressDialog.dismiss();
            if (CommonUtils.isNullOrEmpty(rawJsonResponse)) {
                Toast.makeText(AddContactActivity.this, "?,?", 0).show();
                return;
            }

            Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse);
            if (lm.get("status").toString() != null && lm.get("status").toString().equals("yes")) {
                Toast.makeText(AddContactActivity.this, "?", 0).show();
                Log.d("log message==" + lm.get("message").toString());
                if (!CommonUtils.isNullOrEmpty(lm.get("result").toString())) {
                    Map<String, Object> lmres = JsonToMapList.getMap(lm.get("result").toString());
                    String nickname = lmres.get("nickname").toString();
                    //String age = lmres.get("age").toString();
                    //String sex = lmres.get("sex").toString();
                    String headurl = lmres.get("headurl").toString();
                    sendaddname = lmres.get("user").toString();

                    if (CommonUtils.isNullOrEmpty(sendaddname)) {
                        Toast.makeText(AddContactActivity.this, "?", 0).show();
                        return;
                    }

                    if (!CommonUtils.isNullOrEmpty(nickname)) {
                        //tv_user_nicheng.setText(nickname);
                        searchedUserLayout.setVisibility(View.VISIBLE);
                        nameText.setText(nickname);
                        PreferenceUtils.getInstance(AddContactActivity.this).setSettingUserNickName(nickname);
                    } else if (!CommonUtils.isNullOrEmpty(headurl)) {
                        //tv_user_xingbie.setText(sex);
                        //?
                        ImageLoader.getInstance().displayImage(headurl, avatar, ImageOptions.getOptions());

                    }

                }
            } else {
                if (!CommonUtils.isNullOrEmpty(lm.get("message").toString()))
                    Toast.makeText(AddContactActivity.this, lm.get("message").toString(), 0).show();
                return;
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData,
                Object errorResponse) {
            // TODO Auto-generated method stub
            progressDialog.dismiss();
            Toast.makeText(AddContactActivity.this, ",?", 0).show();
            return;
        }

        @Override
        protected Object parseResponse(String rawJsonData, boolean isFailure) throws Throwable {
            // TODO Auto-generated method stub
            return null;
        }

    };
}

From source file:com.hardcopy.retrowatch.RetroWebView.java

public void initialize(Context c, IWebViewListener l) {
    mContext = c;//from   www . j a  v  a 2 s.c o  m
    mWebViewListener = l;
    mIMM = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);

    //-----------------------------------------------------------------------------
    // Initialize layout
    //-----------------------------------------------------------------------------
    mEditURL.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
                actionLoadURL(null);
                // InputMethodManager.HIDE_IMPLICIT_ONLY as the second parameter to ensure 
                // you only hide the keyboard when the user didn't explicitly force it to appear (by holding down menu)
                mIMM.hideSoftInputFromWindow(mEditURL.getWindowToken(), 0);
            }
            return true;
        }
    });

    mMsgWait = mContext.getString(R.string.warning_loading_wait);

    //-----------------------------------------------------------------------------
    // Create Web-View and set clients
    //-----------------------------------------------------------------------------
    mWebViewClient = new RetroWebViewClient();
    mChromeClient = new RetroChromeClient();
    mWebView.setWebViewClient(mWebViewClient);
    mWebView.setWebChromeClient(mChromeClient);

    // Set Web-View features
    mWebViewSettings = mWebView.getSettings();
    mWebViewSettings.setJavaScriptEnabled(true);
    mWebView.addJavascriptInterface(new AndroidBridge(), "hotclip"); // param 2 : JavaScript use this parameter
    // ex) javascript call: function getResult() { window.hotclip.setResult('ERROR'); }

    mWebViewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    mWebViewSettings.setBuiltInZoomControls(true);
    mWebViewSettings.setLoadWithOverviewMode(true);
    mWebViewSettings.setUseWideViewPort(true);
    //mWebViewSettings.setDatabaseEnabled(true);
    mWebViewSettings.setDomStorageEnabled(true);

    // Set cache size to 8 mb by default. should be more than enough
    //      mWebViewSettings.setAppCacheMaxSize(1024*1024*8);

    // Enable HTML5 Application Cache
    //      String appCachePath = mContext.getCacheDir().getAbsolutePath();
    //      mWebViewSettings.setAppCachePath(appCachePath);
    //      mWebViewSettings.setAllowFileAccess(true);
    //      mWebViewSettings.setAppCacheEnabled(true);
    //      mWebViewSettings.setCacheMode(WebSettings.LOAD_DEFAULT);

    //      GeoClient geo = new GeoClient();
    //      webview.setWebChromeClient(geo);
    //      mWebViewSettings.setGeolocationEnabled(true);
    //      mWebViewSettings.setGeolocationDatabasePath(<path>);

}

From source file:com.imalu.alyou.activity.GroupsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_groups);

    instance = this;
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    UserKeyRequest userKeyReq = new UserKeyRequest();
    userKeyReq.setUserKey(AlUApplication.getMyInfo().getKey());

    NetManager.execute(NetManager.GROUPS_REQUEST_OPERATION, userKeyReq, new JsonHttpResponseHandler() {
        @Override/*  w  ww. j av a2 s  . c o m*/
        public void onSuccess(int statusCode, Header[] headers, JSONArray response) {
            try {
                GroupListResponse groups = new GroupListResponse();
                groups.setJsonObject(response);
                AlUApplication.setGroups(groups);

                for (Iterator<ConversationGroup> iter = AlUApplication.getGroups().getConversationGroupList()
                        .iterator(); iter.hasNext();) {
                    ConversationGroup group = (ConversationGroup) iter.next();
                    GroupKeyRequest groupKeyReq = new GroupKeyRequest();
                    groupKeyReq.setGroupKey(group.getGroupKey());

                    NetManager.execute(NetManager.GROUP_MEMBER_REQUEST_OPERATION, groupKeyReq,
                            new JsonHttpResponseHandler() {
                                @Override
                                public void onSuccess(int statusCode, Header[] headers, JSONArray response) {
                                    try {
                                        MemberListResponse memberlistRes = new MemberListResponse();
                                        memberlistRes.setJsonObject(response);
                                        AlUApplication.setGroupMemberList(memberlistRes);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                }

                generateList();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}