Context context=getApplicationContext();
VideoView videoView =(VideoView)context.findViewById(R.id.videoView1);
cannot find service class on video view
-
24-09-2022 - |
문제
Hi i want to know how to run a service in background of an activity like i am using a video view and i want it to run while other activity are running
how to do this? VideoView videoView =(VideoView)findViewById(R.id.videoView1);
//Creating MediaController
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
//specify the location of media file
Uri uri=Uri.parse(Environment.getExternalStorageDirectory() + "/video.mp4");
//Setting MediaController and URI, then starting the videoView
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
can any one help me how to bind service with this video view so it run in background?
해결책
다른 팁
You need to bind the Service
to your Activity
if you need to interact with it. You can pass your VideoView
throw your IBinder
implementation if you need to handle it through the service. You should also run the Service
in the foreground if you want to avoid it getting killed.
제휴하지 않습니다 StackOverflow