Android Question Overlay Window library problem

tomi85

Member
Licensed User
Longtime User
Hi

Im using this library in my application.

It is working with Sdk set < 26 when I set Sdk to 26 I have error.

Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@1a540d8 -- permission denied for window type 2003

Thanks for help
 

tomi85

Member
Licensed User
Longtime User
thanks

now I have eror when compiling

src\b4a\example\starter.java:1480: error: incompatible types: starter cannot be converted to View

I put this code in my service when I create OW window

#if JAVA

import android.content.Context;
import android.graphics.PixelFormat;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.Toast;
//import java.lang.Boolean;
import android.os.PowerManager;
import java.lang.System;
import android.os.Build;


private WindowManager windowManager;
private WindowManager.LayoutParams params;
private Context context;

public void setperm(Context context) {

this.context = context;
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

if (Build.VERSION.SDK_INT >= 26) {
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,//TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSLUCENT);
} else {
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,//TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSLUCENT);
}

windowManager.addView(this, params);
}

#End if
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Please use [CODE]code here...[/CODE] tags when posting code.

codetag001.png

codetag002.png

codetag003.png
 
Upvote 0
Top