SuperToasts icon indicating copy to clipboard operation
SuperToasts copied to clipboard

API 28 Exception: Unable to add window -- token null is not valid;

Open 1371030 opened this issue 7 years ago • 5 comments

API 28 Exception: Unable to add window -- token null is not valid; is your activity running?

1371030 avatar Sep 26 '18 09:09 1371030

Hello, I got the same problem[

ghost avatar Dec 21 '18 08:12 ghost

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; } }

HEZI0427 avatar Feb 01 '19 04:02 HEZI0427

you can refer to https://github.com/Dovar66/DToast

Dovar66 avatar Feb 14 '19 06:02 Dovar66

use this + overlay permission

(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
							 WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
							 WindowManager.LayoutParams.TYPE_PHONE)

Behrouz-m avatar Mar 02 '19 11:03 Behrouz-m

Salam, In my case, the issue was resolved after replace SuperToast with SuperActivityToast

fatemi2020 avatar Aug 19 '22 17:08 fatemi2020