In my media player, I added a view that appears if a menu key is pressed, I want it to be hidden after a while, i.e. the user does not want to see the view. The view is horizontal, and I want it to hide for a few seconds that the user will not press the right or left key.
I use my logic here, but it didn’t work: “Similar to my view of the show”
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
super.onKeyDown(keyCode, event);
lastUsed = System.currentTimeMillis();
case KeyEvent.KEYCODE_MENU:
similar.setVisibility(View.VISIBLE);
similar.bringToFront();
similar.requestFocus();
similar.bringToFront();
nowHide()
}
public void nowHide(){
new Thread(new Runnable() {
public void run() {
while(true){
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(getLastInteractionTime()+5000 >= System.currentTimeMillis())
{
Log.d("MOVIE PLAY ACTIVITY:SADIP", "check time success");
runOnUiThread(new Runnable() {
public void run() {
similar.setVisibility(View.GONE);
}
});
}
}
}
}).start();
}
public long getLastInteractionTime() {
return lastUsed;
}
public long setLastInteractionTime(int lastInteraction) {
lastUsed = lastInteraction;
return lastUsed;
}
The code never reached
if(getLastInteractionTime()+5000 >= System.currentTimeMillis())
And also I did not know how to stop this flow
How can i do this? Any other methods would be more appreciated. Thanks in advance.
source
share