[target api]
[27->29]
This commit is contained in:
@@ -32,71 +32,23 @@ class MediaPlayerActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
i(SceneConstant.M_BUS_P + TAG, "onResume")
|
||||
i(SceneConstant.M_BUS_P + TAG, "onStart")
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
i(SceneConstant.M_BUS_P + TAG, "onResume")
|
||||
checkPermissionSelf()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
i(SceneConstant.M_BUS_P + TAG, "onResume")
|
||||
i(SceneConstant.M_BUS_P + TAG, "onPause")
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
i(SceneConstant.M_BUS_P + TAG, "onResume")
|
||||
i(SceneConstant.M_BUS_P + TAG, "onStop")
|
||||
}
|
||||
|
||||
fun checkPermissionSelf(){
|
||||
i(SceneConstant.M_BUS_P + TAG, "checkPermissionSelf")
|
||||
val isAllGranted: Boolean = checkPermissionAllGranted(
|
||||
arrayOf<String>(
|
||||
Manifest.permission.RECORD_AUDIO, // Manifest.permission.CAMERA,
|
||||
Manifest.permission.BLUETOOTH,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
)
|
||||
)
|
||||
if (isAllGranted&&Settings.canDrawOverlays(this)) {
|
||||
restartActivity()
|
||||
return
|
||||
}
|
||||
RxUtils.createSubscribe {
|
||||
checkPermissionSelf()
|
||||
}
|
||||
}
|
||||
|
||||
fun restartActivity(){
|
||||
val activityList = ActivityUtils.getActivityList()
|
||||
activityList.forEach {
|
||||
if (it is MainLauncherActivity) {
|
||||
i(SceneConstant.M_BUS_P + TAG, "restartActivity")
|
||||
val options = ActivityOptions.makeBasic()
|
||||
options.launchDisplayId = Display.INVALID_DISPLAY
|
||||
val intent = Intent(this, MainLauncherActivity::class.java)
|
||||
startActivity(intent, options.toBundle())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkPermissionAllGranted(permissions: Array<String>): Boolean {
|
||||
for (permission in permissions) {
|
||||
if (ContextCompat.checkSelfPermission(
|
||||
this,
|
||||
permission
|
||||
) != PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
// 只要有一个权限没有被授予, 则直接返回 false
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -245,7 +245,7 @@ ext {
|
||||
compileSdkVersion : 33,
|
||||
buildToolsVersion : "29.0.2",
|
||||
minSdkVersion : 23,
|
||||
targetSdkVersion : 27,
|
||||
targetSdkVersion : 29,
|
||||
koomxhook : "com.kuaishou.koom:xhook-static:2.2.0",
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user