I found this. So, far no luck. I used his code, but I’m not able to get past this error..I’m not familiar with inflaters. So could someone explain this code?
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup mTopView = (ViewGroup) getApplicationContext()
.getLayoutInflater().inflate(R.layout.activity_invisible, null);
getWindow().setAttributes(params);
wm.addView(mTopView, params);
This part of the code:
ViewGroup mTopView = (ViewGroup) getApplicationContext()
.getLayoutInflater().inflate(R.layout.activity_invisible, null);
Gives me this error The method getLayoutInflater() is undefined for the type Context
Can someone explain what I’m doing wrong?
getLayoutInflater() is a method in Activity, not Context.
You must be using an instance of an Activity to call it, or else it will not work.
However, you can probably use the LayoutInflater
inflateryou create on the line before the one with the error. Something like: