日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android 悬浮窗权限申请

發(fā)布時(shí)間:2024/3/24 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 悬浮窗权限申请 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

申請方法:

//AndroidManifest.xml添加 <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> if (!Settings.canDrawOverlays(this)) {Intent intent = new Intent();intent.setAction(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);startActivity(intent);}

在申請的時(shí)候出現(xiàn)以下提示:由于此功能會(huì)導(dǎo)致您的手機(jī)速度變慢.....

定位源碼:android/packages/apps/Settings/src/com/android/settings/applications/manageapplications/ManageApplications.java

android/packages/apps/Settings/src/com/android/settings/Utils.java


isSystemAlertWindowEnabled 會(huì)判斷當(dāng)前設(shè)備是低內(nèi)存設(shè)備并android版本大于等于Q則關(guān)閉此功能。

isLowRamDevice是通過屬性ro.config.low_ram或debug模式屬性判斷,源碼:android/frameworks/base/core/java/android/app/ActivityManager.java

private static final boolean DEVELOPMENT_FORCE_LOW_RAM =SystemProperties.getBoolean("debug.force_low_ram", false);/*** Returns true if this is a low-RAM device. Exactly whether a device is low-RAM* is ultimately up to the device configuration, but currently it generally means* something with 1GB or less of RAM. This is mostly intended to be used by apps* to determine whether they should turn off certain features that require more RAM.*/public boolean isLowRamDevice() {return isLowRamDeviceStatic();}/** @hide */@UnsupportedAppUsagepublic static boolean isLowRamDeviceStatic() {return RoSystemProperties.CONFIG_LOW_RAM ||(Build.IS_DEBUGGABLE && DEVELOPMENT_FORCE_LOW_RAM);}

android/frameworks/base/core/java/com/android/internal/os/RoSystemProperties.java

public static final boolean CONFIG_LOW_RAM =SystemProperties.getBoolean("ro.config.low_ram", false);

android/frameworks/base/core/java/android/os/Build.java

@UnsupportedAppUsagepublic static final boolean IS_DEBUGGABLE =SystemProperties.getInt("ro.debuggable", 0) == 1;

在對應(yīng)的mk設(shè)置ro.config.low_ram為false:

PRODUCT_PROPERTY_OVERRIDES += \ro.config.low_ram=false \

完美解決~~~

總結(jié)

以上是生活随笔為你收集整理的android 悬浮窗权限申请的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。