私はサービスで曲を再生しようとしていますが、私はバックボタンを押したときに、それはので、私はonbackpress
メソッドをオーバーライドし、曲を演奏を停止が、私はそれがあることを行うとき、直接に私をもたらしバック押すと、曲を再生しますホーム画面。私は別の断片で複数の曲のカテゴリを表示し、インターフェイスを介してarraylistと位置を渡しています。この部分はうまくいきますが、私は戻ってボタンを押すと、私はonpauseメソッドをオーバーライドしようとしましたが、これを達成する正しい方法は何ですか?私の演技方法はありますか? ボタン
@Override public void onFragmentInteraction(ArrayList<Songfileinfo> songarr, int position) { playAudio(songarr, position); Log.v(""+songarr.size(),"I GOT THE SIZE"); } private void playAudio(ArrayList<Songfileinfo> arrayList, int audioIndex) { //Check is service is active if (!serviceBound) { //Store Serializable audioList to SharedPreferences StorageUtil storage = new StorageUtil(getApplicationContext()); storage.storeAudio(arrayList); storage.storeAudioIndex(audioIndex); Intent playerIntent = new Intent(this, MediaPlayerService.class); startService(playerIntent); bindService(playerIntent, serviceConnection, Context.BIND_AUTO_CREATE); } else { //Store the new audioIndex to SharedPreferences StorageUtil storage = new StorageUtil(getApplicationContext()); storage.storeAudio(arrayList); storage.storeAudioIndex(audioIndex); //Service is active //Send a broadcast to the service -> PLAY_NEW_AUDIO Intent broadcastIntent = new Intent(Broadcast_PLAY_NEW_AUDIO); sendBroadcast(broadcastIntent); } }
私はbackpressを上書きmethorそれはそれはあなたの活動にバインドされているホーム画面
バックグラウンドでの通知が表示されますが、バックボタンを押すとその曲は再生されません – SAVVY