Reputation: 4007
Where do I start?
I don't know what functions or permissions will I use to make this. No root required.
The view look like this, the camera button on the right side, it is floating and visible to other apps, if you push it, it will capture a screenshot.
Note: I will not make make a screenshot app, this is only an example of what I want to achieve.
Upvotes: 25
Views: 38954
Reputation: 11
Try this:
if(!isSystemAlertPermissionGranted(MainActivity.this)){
requestSystemAlertPermission(MainActivity.this,1);
}
startService(new Intent(getApplicationContext(), Overlay.class));
And:
public static void requestSystemAlertPermission(Activity context, int requestCode) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
return;
final String packageName = context == null ? context.getPackageName() : context.getPackageName();
final Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + packageName));
if (context != null)
context.startActivityForResult(intent, requestCode);
else
context.startActivityForResult(intent, requestCode);
}
@TargetApi(23)
public static boolean isSystemAlertPermissionGranted(Context context) {
final boolean result = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || Settings.canDrawOverlays(context);
return result;
}
Upvotes: 1
Reputation: 12444
this called
Draw Over Other Apps
check these answers
"DRAW OVER OTHER APP" is which permission in android
How to draw a view on top of everything?
(from Morrison Chang) What APIs in Android is Facebook using to create Chat Heads?
Upvotes: 16