Search code examples
android-tvamazon-fire-tv

How to detect when a fire tv application is minimized?


Is there a way to detect when a user minimizes the fire tv application by pressing the home icon on the remote?


Solution

  • No there is no key event to detect the Home button key press but u can check for onStop method of the activity and where u can add additional condition whether backkey pressed or not as its always called before onStop().

    boolean flag=false;
    
        @Override
            public void onBackPressed() {
                super.onBackPressed();
                flag=true;
            }
        
            @Override
            protected void onStop() {
                super.onStop();
                if(flag){ 
                //back button pressed
                  } 
                else{ 
               // Home button pressed
               }
            }