android - Overlay button prevents dialogs from appearing, using TYPE_SYSTEM_ALERT -
i adding notification icon overlaid in corner of activities when there important things user needs know. have working, except prevents spinners, dialogs, , edittext working. spinners appear work, except can't see them, if touch it, touch again, option gets selected, spinner dialog doesn't appear.
base activity other activities extend:
public abstract class loggedinactivity extends gaugesactivity { private static final string tag = "loggedinactivity"; private windowmanager wm; private boolean overlaycreated = false; private linearlayout moverlay; private imageview moverlayimageview; @override protected void onresume(){ super.onresume(); wm = (windowmanager) getsystemservice(window_service); sharedpreferences prefs = getsharedpreferences(prefs_name, mode_private); string duplicatetruckguid = prefs.getstring("duplicatetruckguid", ""); if (! duplicatetruckguid.isempty()){ createoverlay(); } } protected void createoverlay(){ if (overlaycreated) return; // create system overlay windowmanager.layoutparams params = new windowmanager.layoutparams( windowmanager.layoutparams.wrap_content,windowmanager.layoutparams.wrap_content, windowmanager.layoutparams.type_system_alert, // windowmanager.layoutparams.type_application_panel, windowmanager.layoutparams.flag_not_focusable | windowmanager.layoutparams.flag_not_touch_modal, pixelformat.translucent); params.gravity = gravity.right | gravity.bottom; params.token = getwindow().getdecorview().getrootview().getwindowtoken(); layoutinflater inflater = (layoutinflater) getsystemservice(layout_inflater_service); moverlay = (linearlayout) inflater.inflate(r.layout.overlay_notification, null); // moverlayimageview = (imageview) moverlay.findviewbyid(r.id.overlay_notification_image); try { wm.addview(moverlay, params); final context context = this; moverlay.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { intent intent = new intent(context, notificationsactivity.class); intent.setflags(intent.flag_activity_clear_top); startactivity(intent); return true; } }); } catch (exception e){ log.e(tag, e.tostring()); log.i(tag, e.tostring()); toast.maketext(this, e.tostring(), toast.length_short).show(); } }
overlay_notification.xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="bottom" android:background="@drawable/black_transparent_overlay"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/overlay_notification_image" android:src="@drawable/ic_warning_active" android:layout_margin="@dimen/normal_padding"/> </linearlayout>
you can use type_system_error
instead of type_system_alert
.
also, flag_not_touch_modal
implicitly set flag_not_focusable
don't need add manually.
however, suggest consider alternative pointed out commonsware.
Comments
Post a Comment