Android Stop Background Music

前端 未结 9 960
生来不讨喜
生来不讨喜 2020-12-01 02:29

EDIT - FOUND A EASY 5-10 LINE SOLUTION!!! See MY OWN ANSWER BELOW!!! YAY!!!!!!!!!

I\'ve searched for 5 hours, dozens of SO posts, no answers, and this seems like t

9条回答
  •  时光取名叫无心
    2020-12-01 03:01

    Why don't you just make a button to stop the music its so much easier and you don't have to force close everytime

    Button exit =(Button) findViewById(R.id.exit);
    
        exit.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v)
                {
                    // TODO: Implement this method
    
                    startActivity(new Intent("com.justme.worldexplorer.EXIT"));             
                    finish();
                    Music I'd.stop();}});}
    

    There you go and so the key hardware button back dosent leave if you press by accident

    public boolean onKeyDown(int KeyCode,KeyEvent event){
    
    
        return false;
    }
    

    And that's it set it up in the manifest and run if any problems let me know

提交回复
热议问题