Disable text "Settings" when click recent button android - android

Why when I press this button, a pop up (with text Settings) is displayed in my app ?
How can I remove it?

For handling this keys you need to override this method of the Activity
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode ==KeyEvent.KEYCODE_MENU) {
//return true if you want block button menu
return true;
}
return super.onKeyDown(keyCode, event);
}

Related

How to keep DropDownList of AutoCompleteTextView opened after pressing the Back key?

i am using AutoCompleteTextView in my Activity and i need it's DropDownList to be shown all the time (it's the only View in Window), even after Back key press. I need to dismiss soft keyboard instead.
I tried to override Activity's onBackPressed method, but it's not used at all, so BackPressed event is being handled somewhere "higher". So i tried to find out where, but AutoCompleteTextView has no onBackPressed method defined.
Any advices?
You can create your custom AutoCompleteTextView and Override the method onKeyPreIme(int keyCode, KeyEvent event)
I also realized that this method is called 2 times, I'm running my code only in the second time. Here is the example:
#Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == 1) {
//add your code here
return true;
}
return super.onKeyPreIme(keyCode, event);
}
You may try this
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
//Your back key press logic
}
return true;
}
Remember to return true to prevent this event from being propagated further, or false to indicate that you have not handled this event and it should continue to be propagated.

How to catch event with hardware back button on android?

How to catch event with hardware back button on android ? I need to supress user to go back and I when click on back button on phone to show message and not to go on previous activity. How to do that ?
you can do by this
override the onBackPressed() method into your Activity like this way
public void onBackPressed(){
// do something here and don't write super.onBackPressed()
}
override the onKeyDown() method
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch(keyCode){
case KeyEvent.KEYCODE_BACK:
// do something here
return true;
}
return super.onKeyDown(keyCode, event);
}
Override the method onBackPressed() in whatever Activity you want to create a different behaviour to the back button.
These question are equal to yours (and could have been found by a simple search):
how to disable back button in android
Disable back button in android
You can suppress user "back" action with onKeyDown() in your activity like this:
#Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK))
{
//do actions like show message
return false;
}
return super.onKeyDown(keyCode, event);
}

Android listen for backbutton longclick

I am overriding the backbutton with a onBackPressed() function
how do I also detect long clicks on the backbutton? Is there an equivalent of #Override onBackLongPressed() ?
This might help you (Check the first comment) - Android long key press
From Android 2.0, Activity contains the method
public boolean onKeyLongPress(int keyCode, KeyEvent event)
For exemple, a long key press on the back button would be :
#Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK)
{
// do your stuff here
return true;
}
return super.onKeyLongPress(keyCode, event);
}
Check "Story 2" here. There's not a shortcut for it like there is onBackPressed().
I think you'll have to use onKeyLongPress and handle the KEYCODE_BACK event yourself.

Android Home button click ignoring saved state?

Can I ignore the previous stage of application after tapping Home button in android?
So that I can get the application from initial screen.
Use like this.If now you are in LastActivity and you want to go back to the First Activity and there is more activity in between then if you want to go first from last use
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(autoSearch)
if (keyCode == KeyEvent.KEYCODE_HOME) {
Log.d("click","HOMEButtonclicked");
LastActivity.this.startActivity(new Intent(LastActivity.this, FirstActivity.class));
moveTaskToBack(false);
return true;
}
return super.onKeyDown(keyCode, event);
}

How to disable QSB..?

When a user presses the Search hard key on the device, Android shows the Quick Search Bar. How do I disable the Quick Search Bar?
override onKeyDown in your activity:
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH) {
return true;
} else return super.onKeyDown(keyCode, event);
}
In order to completely disabled the Quick Search Bar, override the method onSearchRequested()and return true unconditionally.

Categories

Resources