Home > OS >  Record from a from a background-service using MediaProjection API: is this kind of approach the only
Record from a from a background-service using MediaProjection API: is this kind of approach the only

Time:10-12

  Intent dialogIntent = new Intent(BackgroundService.this, ScreenShotActivity.class);
  dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  startActivity(dialogIntent);

I want to ask you if starting the activity ScreenShotActivity.class, which is the class for the MediaProjection implementation, from a background-service is the only way to record everything happening on screen.

Source: How to take a Screenshot from a background-service class using MediaProjection API?

Or is it possible to implement everything of the MediaProjection API inside the service itself, without needing an "util" activity?

CodePudding user response:

is it possible to implement everything of the MediaProjection API inside the service itself, without needing an "util" activity?

No. The user needs to agree to allow your app to record the screen, and the system-supplied dialog for that is displayed via startActivityForResult(). That, in turn, requires an activity.

  • Related