23

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.

enter image description here

Note: I will not make make a screenshot app, this is only an example of what I want to achieve.

NaviRamyle
  • 3,827
  • 1
  • 28
  • 49
  • 1
    I have a tutorial on the same here : http://myandroidtuts.blogspot.in/2013/05/facebook-chat-heads-feature.html – Adnan Mulla Dec 09 '13 at 03:50
  • @NaviRamyle - can you tell me what app that screenshot was taken from? – R. Pope May 20 '16 at 17:13
  • Possible duplicate of [What APIs are used to draw over other apps (like Facebook's Chat Heads)?](https://stackoverflow.com/questions/15975988/what-apis-are-used-to-draw-over-other-apps-like-facebooks-chat-heads) – Ryan M May 14 '20 at 06:47
  • @AdnanMulla dead link (yes I know it's over 6 years old) – Artemis Jul 19 '20 at 09:32

2 Answers2

14

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?

Community
  • 1
  • 1
Mohammad Ersan
  • 11,926
  • 8
  • 48
  • 72
1

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;
}
David LM
  • 11
  • 2