can I show coming notification always on top of all other notification . in new version lollipop it is default...but what to do for others previous versions .i am using Samsung note 2 device.
In order to put it there you have to add a flag to the LayoutParams
of your WindowManager and after that add the NotificationView.
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
mWindowManager.addView(mHeadsUpNotificationView, lp);
Related
my application helps testers to find inconsistencies in layouts and makes it easier to work with the UI part using the grid layout overlay. but since android 12 (31 sdk) all clicks are suppressed by the system because they are "untrusted touch"
have any ideas?
P.S. in the article on medium it is suggested to use one of the approaches: Bubbles, Picture-in-Picture, Notifications, but this is not suitable for the gridlayout approach
link to untrusted touch android doc
Code example:
private fun showGrid() {
val overlayFlag = if (Build.VERSION.SDK_INT >= 26)
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
else WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY
params = WindowManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
overlayFlag,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE or
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT
)
windowManager = getSystemService(Context.WINDOW_SERVICE) as WindowManager
gridOverlay = GridOverlay(this, prefHelper.gridColor, prefHelper.gridSize)
gridOverlay?.alpha = prefHelper.gridAlpha
windowManager!!.addView(gridOverlay, params)
}
InputManager , maximumObscuringOpacityForTouch didn't solve the problem
other flags in the WindowManager also did not help.
what can be done according to the android documentation is using the Accessibility service, but this is not our approach as I don't want to be banned by Google because of using Accessibility service not for its intended purpose.
I have an App on the play store. This app basically creates an overlay on top of all the apps with some colors, It works perfectly for anything below Android 12. But, since Android 12 it no longer works. I can still interact with my application, but once minimized I no longer can click on anything or change anything at all. I have to restart the device to close the application.
val params = WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY
else WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
or WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT
)
This is how I create the overlay on top. I checked the documentation, but could not find any information. I will be grateful if I can get any help and suggestions to fix this issue.
Set alpha to window manager params, its works for me.
Try below snippet code:
if (Build.VERSION.SDK_INT >= 31)
{
params.alpha = 0.8f;
}
A problem I am facing that I have to hide all notification on lock screen on os 8.
Functionality: I have to develop lock screen and no other app will use when the lock screen is on the foreground.
Let me explain the whole problem:
1) I have developed custom lock screen. Please see below code
public WindowManager winManager;
public RelativeLayout wrapperView;
// Adding a View on Top
WindowManager.LayoutParams localLayoutParams;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
localLayoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN,
PixelFormat.TRANSLUCENT);
} else {
localLayoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN,
PixelFormat.TRANSLUCENT);
}
this.winManager = ((WindowManager) getApplicationContext().getSystemService(WINDOW_SERVICE));
this.wrapperView = new RelativeLayout(getBaseContext());
this.wrapperView.setBackgroundColor(getResources().getColor(R.color.white));
getWindow().setAttributes(localLayoutParams);
View.inflate(this, R.layout.lock_screen_activity, this.wrapperView);
this.winManager.addView(this.wrapperView, localLayoutParams);
It perfectly works on OS 7 and below. Notification access is not available on custome lock screen.
But on OS 8, on the lock screen other app notification is display as per category. and user can reply in notification. So that i have to prevent on lock screen.
app Gradle like:
minSdkVersion 19
targetSdkVersion 26
I have already tried below option : https://developer.android.com/training/system-ui/status
Please guys help me to solve this problem. Thank you in advance...
My app shows views above the lockscreen, until now I used the following code:
windowParams = new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, 65794, -2);
windowParams.type = Utils.isSamsung(getApplicationContext()) ? WindowManager.LayoutParams.TYPE_TOAST : WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
windowManager.addView(frameLayout, windowParams);
This code doesn't seem to work anymore on Android O, instead, now the lockscreen is shown above the view, and the view only becomes visible after the user swipes away the lockscreen.
Granted, it could just be a bug since Android O is still in beta, but it's also possible that I missed one of Googles notes about "what's new in O".
It's no longer possible to draw over the lockscreen and other important UI elements (status bar, etc), Google removed this feature in Android O.
Source:
https://issuetracker.google.com/issues/36574245
I'm using WindowManager.LayoutParams class using TYPE_SYSTEM_ALERT to get an activity on top of everything. Everything is working fine except the display resolution which appears to be magnified, and therefore I'm not able to see the full content of the layout.
Here is the screenshot
Layout Snapshot
(Extremely sorry for not uploading the image directly due to my low reputation as I'm new to StackOverflow)
My code for WindowManager.LayoutParams is
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);
params.gravity = Gravity.RIGHT | Gravity.TOP;
wm = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
mTopView = (ViewGroup) getLayoutInflater().inflate(R.layout.block_device, null);
getWindow().setAttributes(params);
wm.addView(mTopView, params);
I also tried WRAP_CONTENT instead of FLAG_FULLSCREEN, but it showed an IllegalStateException that ActionBarView can only be used with MatchParent.
Any fixes that I can try out???
In 5.1 as part of extra security system_alert kind of dialog, which writes on top of another application is UI is deprecated. In my application I had one activity which had system_alert dialog it was working until 5.0 but in 5.1 not working (after android.permission.SYSTEM_ALERT_WINDOW permission also its not working). I referred androidxref U can see in the following link http://androidxref.com/5.1.1_r6/xref/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#1639
They will check and throw the exception if app is trying to write on the window of other application
Finally we had to redesign the application to not use System alert kind of dialog
Refer the following code snippet for sample code...
String message = getString(R.string.progress_message);
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setTitle(R.string.progress_title_message);
mProgressDialog.setMessage(message);
mProgressDialog.setProgressStyle(mProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setProgress(0);
mProgressDialog.setCancelable(false);
mProgressDialog.setMax(100);
mProgressDialog.show();`