This.mWmParams = new WindowManager. MWindowManager.getDefaultDisplay().getMetrics(dm) addView(View child) addView(View child, int index) addView(View child, int width, int height) addView(View view, ViewGroup.LayoutParams params) addView(View child, int index, LayoutParams params) 2. MWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE) ĭisplayMetrics dm = new DisplayMetrics() GetColor(this, sharedPreferences.getInt(SharedPrefs.KEY_COLOR_ID, R.color.black))) 1 1 asked at 13:27 Pratik 30.6k 18 84 159 Add a comment 4 Answers Sorted by: 154 Try using this permission in AndroidManifest. WmParams.flags = _NOT_TOUCHABLE | _NOT_FOCUSABLE | _LAYOUT_IN_SCREEN | _WATCH_OUTSIDE_TOUCH | _FULLSCREEN The app requests the user's approval by sending an intent with action ACTIONMANAGEOVERLAYPERMISSION. * These windows are normally placed above all applications, but behind Solution: If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen. The library add the view to window manager directly so it doesn't minimized when user minimized the app. * user interaction with the phone (in particular incoming calls). It look like the problem is about the solution that you use in this library. These are non-application windows providing WmParams = new WindowManager.LayoutParams(_PARENT, Wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE) // Obtain WindowManager val windowManager context.getSystemService (Context.WINDOWSERVICE) as WindowManager // Add view windowManager.addView (rootView, windowParams) // Remove view windowManager. MyView = new LinearLayout(getApplicationContext()) It is the only window type that Android O allows to be displayed over other apps. Usageįrom source file: .TextOverlayService.// myView = new LinearLayout(new ContextThemeWrapper(getApplicationContext(), R.style.Theme_Transparent), null, 0) 1 Answer Sorted by: 7 Use TYPEAPPLICATIONOVERLAY. Source Link DocumentAssign the passed LayoutParams to the passed View and add the view to the window. I have added the 'SYSTEMALERTWINDOW' permission and I have enabled 'Draw over other apps' in app info. I'm trying to create an overlay window but when I try to add the view to the WindowManager, it gives me an exception. Prototype public void addView( View view, ViewGroup.LayoutParams params) WindowManager.addView () causes BadTokenException. IntroductionIn this page you can find the example usage for android.view WindowManager addView.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |