Play background music in all activities of Android app

后端 未结 5 923
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 01:03

I spend about 20 hours until now and my problem there still is . I am creating an android application that has several Activities (mainMenu , aboutUs,setting). I followed th

5条回答
  •  不知归路
    2020-12-07 01:47

    public class serv extends Service{
    
        MediaPlayer mp;
        @Override
        public IBinder onBind(Intent intent) {
            // TODO Auto-generated method stub
            return null;
        }
        public void onCreate()
        {   
            mp = MediaPlayer.create(this, R.raw.b);
            mp.setLooping(false);
        }
        public void onDestroy()
        {       
            mp.stop();
        }
        public void onStart(Intent intent,int startid){
    
            Log.d(tag, "On start");
            mp.start();
        }
    }
    

提交回复
热议问题