When user install Application in mobile, he/she needs to give MediaProjection system service permission to start screen shot feature. Whenever user restart mobile, user needs to give MediaProjection service permission manually every time. I want to make so user will need to give MediaProjection permission only once when Application is installed on mobile so user doesn’t need to assign permission every time whenever mobile will be started.
Other issue is that after some time MediaProjection Service is stopped automatically / randomly.
This code starts MediaProjection system service permisison when we manually enable permission:
MediaProjectionManager projectionManager = (MediaProjectionManager)
_context.getSystemService(MEDIA_PROJECTION_SERVICE);
intent = projectionManager.createScreenCaptureIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
((Activity)_context).startActivityForResult(intent,REQUEST_SCREENSHOT);
This code starts Service class when mobile restarts. So when service starts, it doesn’t set MediaProjection permission automatically.
Intent myIntent = new Intent(context, ScreentshotService.class);
myIntent.setAction(Intent.ACTION_BOOT_COMPLETED);
myIntent.putExtra("code", code);
myIntent.putExtra("data",intent1);
context.startService(myIntent);
I am calling this Service.class after reboot using above code but its not starting the MediaProjection Service.