List of usage examples for android.view.inputmethod InputMethodManager hideSoftInputFromWindow
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags)
From source file:com.twentyfourseven.zira.DriverProfileInformation.java
@Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.btnSeeDriverLocation: // Building Parameters tripId and DriverId if (Util.isNetworkAvailable(DriverProfileInformation.this)) { ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("DriverId", mTripDetailsModel.getGetTrip_DriverId())); params.add(new BasicNameValuePair("TripId", SingleTon.getInstance().getDriverTripId())); Log.d("tag", "GetDriver Location::" + params.toString()); AsyncTaskForZira mWebPageTask1 = new AsyncTaskForZira(DriverProfileInformation.this, "GetDriverLocation", params, false, ""); mWebPageTask1.delegate = (AsyncResponseForZira) DriverProfileInformation.this; mWebPageTask1.execute();/*from w w w . jav a2 s .co m*/ } else { Util.alertMessage(DriverProfileInformation.this, "Please check your internet connection"); } break; case R.id.imageView_Message: InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); layoutDialog.setVisibility(View.VISIBLE); break; case R.id.buttonSend: try { InputMethodManager imm1 = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm1.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); } catch (Exception e) { // TODO: handle exception } if (edtMessage.getText().length() == 0) { Util.alertMessage(DriverProfileInformation.this, "Please Write Message"); } else { String userid = mTripDetailsModel.getGetTrip_DriverId(); String message = edtMessage.getText().toString(); String trigger = "sms"; Log.i("tag", "userid:" + userid); Log.i("tag", "message:" + message); Log.i("tag", "trigger:" + trigger); // Building Parameters if (Util.isNetworkAvailable(DriverProfileInformation.this)) { ArrayList<NameValuePair> params1 = new ArrayList<NameValuePair>(); params1.add(new BasicNameValuePair("Id", userid)); params1.add(new BasicNameValuePair("message", message)); params1.add(new BasicNameValuePair("trigger", trigger)); Log.d("tag", "SendRequest::" + params1.toString()); AsyncTaskForZira mWebPageTask = new AsyncTaskForZira(DriverProfileInformation.this, sendMessages, params1, true, "Sending message..."); mWebPageTask.delegate = (AsyncResponseForZira) DriverProfileInformation.this; mWebPageTask.execute(); } else { Util.alertMessage(DriverProfileInformation.this, "Please check your internet connection"); } // new SendMessageParsing().execute(); edtMessage.setText(""); } break; case R.id.imageViewDelete: try { InputMethodManager imm1 = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm1.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); } catch (Exception e) { // TODO: handle exception } edtMessage.setText(""); layoutDialog.setVisibility(View.GONE); break; /*case R.id.imageView_Phone: Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse(jsonmobileno)); startActivity(callIntent); System.err.println("callllllllll"); break;*/ } }
From source file:com.chalmers.schmaps.CheckInActivity.java
/*************************************************************************** * When user enters her/his name and presses check-in the information is sent to an external server * Returened is a jsonobject with all postions where people have checked in the last hour * Start new activity that will show the information on a map *************************************************************************/ public void onClick(View v) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(enterName.getWindowToken(), 0); checkin = true;// ww w. j a v a 2 s . co m username = enterName.getText().toString(); //removes white signs username.trim(); //Removes illegal characters to prevent sql injection username = username.replaceAll("[^[a-z][A-Z][0-9]]", ""); //if the user have not entered a name the name is set to unknown if (username.equals("")) { username = "Unknown"; } connectExternalDatabase(); checkin = false; }
From source file:com.amazonaws.devicefarm.android.referenceapp.Fragments.NavigationDrawerFragment.java
/** * Creates and initializes the drawer with the drawer adapter * @param fragmentId/*from ww w . j a v a 2 s .c o m*/ * @param drawerLayout * @param data * @param toolbar * @param listener */ public void setUp(int fragmentId, DrawerLayout drawerLayout, List<DrawerCategoryModel> data, Toolbar toolbar, DrawerAdapter.OnItemClickListener listener) { drawerAdapter = new DrawerAdapter(data, getActivity(), listener, drawerLayout, getActivity().findViewById(fragmentId)); recycleView.setAdapter(drawerAdapter); recycleView.setHasFixedSize(true); recycleView.setLayoutManager(new LinearLayoutManager(getActivity())); final InputMethodManager inputMethodManager = (InputMethodManager) getActivity() .getSystemService(INPUT_METHOD_SERVICE); final ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(getActivity(), drawerLayout, toolbar, R.string.app_name, R.string.app_name) { @Override public void onDrawerSlide(View drawerView, float slideOffset) { inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);//TODO utility? super.onDrawerSlide(drawerView, slideOffset); } }; drawerLayout.setDrawerListener(drawerToggle); drawerLayout.post(new Runnable() { @Override public void run() { drawerToggle.syncState(); } }); }
From source file:com.mastercard.masterpasswallet.fragments.addcard.VerifyCardFragment.java
private void hideKeyboard() { // Check if no view has focus: View view = getActivity().getCurrentFocus(); if (view != null) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }/*from w w w. j av a 2 s . c om*/ }
From source file:app.hanks.com.conquer.activity.BaseActivity.java
/** * ?? hideSoftInputView/* ww w . j a va2s.c om*/ */ public void hideSoftInputView() { InputMethodManager manager = ((InputMethodManager) this.getSystemService(Activity.INPUT_METHOD_SERVICE)); if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
From source file:com.alivenet.dmvtaxi.fragment.FragmentRateYourRide.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getView().getWindowToken(), 0); }
From source file:com.cianmcgovern.android.ShopAndShare.Share.java
@Override public void onCreate(Bundle savedInstanceState) { mContext = this; super.onCreate(savedInstanceState); setContentView(R.layout.share);/*from ww w. j a va2 s . c o m*/ Button upload = (Button) findViewById(R.id.uploadButton); upload.setText(R.string.upload); upload.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String userLoc = mLocationEdit.getText().toString(); String userStore = mStore.getText().toString(); // Don't allow empty text fields if (userLoc.length() > 1 && userStore.length() > 1) { runUpload(Results.getInstance(), userLoc, userStore); } else new AlertDialog.Builder(mContext).setTitle(R.string.invalidInput) .setMessage(R.string.invalidFields).show(); } }); Button cancel = (Button) findViewById(R.id.cancelShareButton); cancel.setText(R.string.cancelButton); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mLocationListener != null) mLocationManager.removeUpdates(mLocationListener); finish(); } }); mLocationEdit = (EditText) findViewById(R.id.enterLocation); mLocationEdit.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction()) == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_ENTER)) { InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(mLocationEdit.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); return true; } return false; } }); mStore = (EditText) findViewById(R.id.enterStore); mStore.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction()) == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_ENTER)) { InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(mStore.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); return true; } return false; } }); mSearch = (Button) findViewById(R.id.locationButton); mSearch.setBackgroundResource(R.drawable.search); mSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); if (!CheckFeatures.haveGPS()) { new AlertDialog.Builder(mContext).setTitle("GPS Required") .setMessage("You must have GPS to use this feature").show(); } // Only use GPS if it is enabled else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { mSearch.setEnabled(false); mSearch.setBackgroundResource(R.drawable.world); getLocation(); } else { mGpsDialog = new AlertDialog.Builder(mContext).create(); mGpsDialog.setTitle(R.string.gpsDisabled); mGpsDialog.setMessage(mContext.getText(R.string.gpsDisabledMessage)); mGpsDialog.show(); } } }); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.PostFragment.java
/** * onClick method for the post button. Extracts the textView information, * creates the threadComment object and posts it to the server. * //from w w w .j av a 2s. c o m * @param view * The post button in the PostThreadFragment. */ public void post(View view) { if (geoLocation == null) { geoLocation = new GeoLocation(locationListenerService); } if (geoLocation.getLocation() == null) { ErrorDialog.show(getActivity(), "Could not retrieve location. Please specify a custom location."); return; } if (view.getId() == R.id.post_button) { String title = null; EditText editTitle = null; EditText editComment = (EditText) this.getView().findViewById(R.id.commentBody); ThreadComment threadComment = null; String comment = editComment.getText().toString(); if (thread == null) { editTitle = (EditText) this.getView().findViewById(R.id.titlePrompt); title = editTitle.getText().toString(); } if (title != null && title.equals("")) { ErrorDialog.show(getActivity(), "Title can not be left blank."); } else { Comment newComment = new Comment(comment, image, geoLocation, commentToReplyTo); if (commentToReplyTo != null) { Comment c = thread.findCommentById(thread.getBodyComment(), commentToReplyTo.getId()); c.addChild(newComment); int tag = PreferencesManager.getInstance().getCommentSort(); SortUtil.sortComments(tag, thread.getBodyComment().getChildren()); } else { threadComment = new ThreadComment(newComment, title); CacheManager.getInstance().serializeThreadList(ThreadList.getThreads()); int tag = PreferencesManager.getInstance().getThreadSort(); SortUtil.sortThreads(tag, ThreadList.getThreads()); } if (!ConnectivityHelper.getInstance().isConnected()) { CacheManager cacheManager = CacheManager.getInstance(); if (title == null) { cacheManager.addCommentToQueue(newComment); } else { cacheManager.addThreadCommentToQueue(threadComment); } Toaster.toastShort( "No internet connection detected. Your post will automatically send on connection."); } else { ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setMessage("Getting Location Data"); ThreadManager.startPost(newComment, title, geoLocation, dialog, false); } InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); this.getFragmentManager().popBackStackImmediate(); } } }
From source file:com.njlabs.amrita.aid.aums.AumsActivity.java
private void hideSoftKeyboard() { View view = this.getCurrentFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (view != null) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }// ww w . ja va 2 s .c o m }
From source file:ca.cs.ualberta.localpost.view.MapsView.java
/** * Called when a marker starts being dragged *///from w w w. ja v a2s .c om @Override public void onMarkerDragStart(Marker marker) { // Minimize the keyboard after the 'Find' button is pressed // Source: http://stackoverflow.com/questions/3400028/close-virtual-keyboard-on-button-press InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }