Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsupportedOperationException: Use check() #136

Open
chanjungkim opened this issue Nov 19, 2021 · 0 comments
Open

UnsupportedOperationException: Use check() #136

chanjungkim opened this issue Nov 19, 2021 · 0 comments

Comments

@chanjungkim
Copy link

잘 쓰고 있었는데, 버전업을 하니까 다음과 같은 에러가 뜨면서 권한 밥업이 계속 뜹니다.

java.lang.UnsupportedOperationException: Use check() function
    at com.gun0912.tedpermission.coroutine.TedPermission$Builder.setPermissionListener(TedPermission.kt:20)
    at com.example.my_app.components.ui.entry.EntryActivity$permissionCheck$1.invokeSuspend(EntryActivity.kt:196)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:205)
    at kotlin.coroutines.SafeContinuation.resumeWith(SafeContinuationJvm.kt:41)
    at com.gun0912.tedpermission.coroutine.TedPermission$Builder$check$2$1.onPermissionDenied(TedPermission.kt:30)
    at com.gun0912.tedpermission.TedPermissionActivity.permissionResult(TedPermissionActivity.java:201)
    at com.gun0912.tedpermission.TedPermissionActivity.showPermissionDenyDialog(TedPermissionActivity.java:275)
    at com.gun0912.tedpermission.TedPermissionActivity.onRequestPermissionsResult(TedPermissionActivity.java:267)
    at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7616)
    at android.app.Activity.dispatchActivityResult(Activity.java:7466)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:4392)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4441)
    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1817)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6746)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    private fun permissionCheck() {
        // dynamic permission ic_history_check
        lifecycleScope.launch {
            val permission = TedPermission.create()
                .setRationaleTitle(R.string.rationale_title)
                .setRationaleMessage(R.string.rationale_message)
                .setPermissions(
                    Manifest.permission.BLUETOOTH,
                    Manifest.permission.INTERNET,
                    Manifest.permission.READ_PHONE_STATE,
                    Manifest.permission.WAKE_LOCK,
                    Manifest.permission.ACCESS_WIFI_STATE,
                    Manifest.permission.CHANGE_WIFI_STATE,
                    Manifest.permission.ACCESS_NETWORK_STATE,
                    Manifest.permission.CHANGE_NETWORK_STATE,
                    Manifest.permission.READ_EXTERNAL_STORAGE,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
                    Manifest.permission.READ_EXTERNAL_STORAGE,
                    Manifest.permission.CAMERA
                )
            if (!permission.checkGranted()) {
                permission.setPermissionListener(object : PermissionListener {
                    override fun onPermissionGranted() {
                        initData()
                    }

                    override fun onPermissionDenied(deniedPermissions: MutableList<String>?) {
                        Log.d("test", "deniedPermissions: ${deniedPermissions.toString()}")
                        Toast.makeText(
                            WeakReference(applicationContext).get()!!,
                            "Permission Denied\n" + deniedPermissions.toString(),
                            Toast.LENGTH_SHORT
                        ).show()
                        permissionCheck()
                    }
                }).check()
            } else {
                initData()
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant