PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 12, 2022

[FIXED] How to hide keyboard automatically after sending e-mail using emailIntent

 July 12, 2022     android, android-intent, keyboard, message     No comments   

Issue

There is a page where the user can send e-mail, sms or call its guests when needed. The problem is that when the user sends e-mail to its guest, the keyboard doesn't hide. Even-though I have a small problem solving the issue, It still seems hard to find alike post to solve it. I'll be also making screenshots and placing them in here.

enter image description here enter image description here enter image description here enter image description here

As you can see, the keyboard doesn't hide after sending mail.


Solution

Intent sendIntent = new Intent(Intent.ACTION_SEND);
                            sendIntent.setType("text/plain");
                            sendIntent.putExtra(Intent.EXTRA_EMAIL,
                                    new String[] { **EmailAddress** });
                            startActivityForResult(sendIntent, 1);




   @Override
    protected void onActivityResult(int arg0, int arg1, Intent arg2) {
        super.onActivityResult(arg0, arg1, arg2);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                InputMethodManager inputManager = (InputMethodManager) activity
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                inputManager.hideSoftInputFromWindow(**AnyViewOfScreen**.getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }, 300);
    }


Answered By - Vishal
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing