Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.hss01248:FloatWindowPermission:1.0.1'
}
dependencies {
implementation("com.github.hss01248:FloatWindowPermission:1.0.1")
}
<dependency>
<groupId>com.github.hss01248</groupId>
<artifactId>FloatWindowPermission</artifactId>
<version>1.0.1</version>
</dependency>
libraryDependencies += "com.github.hss01248" % "FloatWindowPermission" % "1.0.1"
:dependencies [[com.github.hss01248/FloatWindowPermission "1.0.1"]]
this repository is aimed to adapt android float window permission in most of phone models and how to request it at runtime </br>
its result is as follows : </br>
if you want to see more,click here
from now on,the models below android M that have been adapted are :
<ul><li>xiaomi:v5,v6,v7,v8</li><li>huawei:partial</li><li>meizu:partial</li><li>360:partial</li><li>others:phones like samsung,sony or other model can directly show the float window, so there is no need to adapt,but if you find one that can not,contact me via my email(zhao_zepeng@hotmail.com) or leave a message on my blog i mentioned above,thanks</li></ul>more details about the models that have been adapted(thanks ruanqin0706 for help):</br>
support api version below 23.
if api version >= 23, please use RxPermission and so on .
ask for permission :(contains the checkPermission logic)
FloatWindowManager.getInstance().askPermission(this);
checkPermission
public boolean checkPermission(Context context)
if has permission ,show the view ,if not, call askPermission
public Dialog showAsTypeToast(View view)
the return type Dialog is just a wrapper of WindowManager ,with a convenient api . to dismiss it ,just call
if(dialog !=null && dialog.isShowing()){
dialog.dismiss();
}
if you want to response to the backpressed event of activity ,you can overide in activity like this:
@Override
public void onBackPressed() {
if(dialog !=null && dialog.isShowing()){
dialog.dismiss();
}else {
super.onBackPressed();
}
}
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.hss01248:FloatWindowPermission:lastest release'
}
lastest release:https://github.com/hss01248/FloatWindowPermission/releases
##6.0/6.0+**##
most models are OK with this way of adaption except meizu:
conclusion:
<font color='red'>until now(2016-11-21), this problem has been solved, we have made a special treatment to the ROM above 6.0 inclue 6.0 in meizu mobiles.</font></br>
##huawei##
here is the test result for huawei mobiles:
conclusion:
waiting for adapted...</br>
##xiaomi##
most of xiaomi mobiles are adapted very well except some paticular models:</br>
here is the conclusion:
##samsung##
almost 100% of the samsung mobiles are adapted very well:
here is the conclusion of samsung:
##oppo&&vivo##
only test a small part of the mobiles and here is the result:
conclusion:</br>
</br>
##others##
we random pick some other models like HTC and Sony and here is the result:
conclusion:</br>