Skip to content

Latest commit

 

History

History
93 lines (61 loc) · 3.07 KB

README_EN.md

File metadata and controls

93 lines (61 loc) · 3.07 KB

Logo

EnFloatingView

Jcenter Muxuan Website

Do not need all permissions, not subject to a variety of domestic ROM restrictions, the default can be displayed within the application suspension window.

Traditional way

For the implementation of traditional suspension Windows and some ancient "black technology" suspension Windows, there must have been many mature cases, and the implementation strategies are basically the following two:

  1. TYPE_SYSTEM_ALERT Type
mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams()
layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;

need permission:

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" ></uses>
  1. TYPE_TOAST / TYPE_PHONE Type

No permission statement is required below 7.1.1. It is hidden by default on models like meizu, huawei and xiaomi, and users need to be guided to open the suspension window.

Traditional solutions

The first scheme can not be adopted by many development because of various restrictions, so the more popular way to achieve the suspension window is the second one.

But we have our own rules:

  • the above models cannot be accepted. The second way to achieve the suspension window still requires users to actively grant permission?
  • it is not acceptable to hide by default on models such as meizu, huawei and xiaomi. Users need to be guided to open the suspension window, like this

权限管理

function

  • the application is displayed without any permission
  • in-app display, all models can display the suspension window by default, without guiding users to do more Settings
  • support drag
  • move beyond screen limits
  • can be automatically attached to the edge of the screen

Instructions

1.gralde dependencies

    compile 'com.imuxuan:floatingview:1.0'

2.Add the following code to onStart and onStop in the base class Activity (note that this must be the base class Activity)

    @Override
    protected void onStart() {
        super.onStart();
        FloatingView.get().attach(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        FloatingView.get().detach(this);
    }

3.Display

    FloatingView.get().add(getApplicationContext());

4.Dismiss

    FloatingView.get().remove();

Rendering

预览图