Open 1371030 opened 6 years ago
Hello, I got the same problem[
API 28 Exception: Unable to add window -- token null is not valid; is your activity running?
Step 1 : replace SuperToast WindowManager.LayoutParams.TYPE_TOAST by WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
Step 2 : request android.permission.SYSTEM_ALERT_WINDOW permission runtime
if (Build.VERSION.SDK_INT >= 23) { if (!Settings.canDrawOverlays(getApplicationContext())) { Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())); startActivityForResult(intent, 10); return; } }
you can refer to https://github.com/Dovar66/DToast
use this + overlay permission
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
WindowManager.LayoutParams.TYPE_PHONE)
Salam,
In my case, the issue was resolved after replace SuperToast
with SuperActivityToast
API 28 Exception: Unable to add window -- token null is not valid; is your activity running?