How to start Media Projection Service when Phone is reboot in android?

by kra.rd.test   Last Updated April 15, 2018 12:11 PM

When user install App in mobile, user needs give MediaProjection system service permisison to start screenshot feature. Whenever user restart mobile, user needs to give MediaProjection service permission every time. I want to make so user will need to give MediaProjection permission only once when App is installed on mobile so user doesn’t need to assign permission every time whenver mobile is started.

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);
Tags : applications


Related Questions




Image and Video Files not showing up in Gallery

Updated April 08, 2015 18:04 PM