0

i have a background service that collecte some rss data news and i need to show just a small view or small activity defiling rss content (no overlay other app)that defile the news as long as the service is alive but i dont now how to acomplich the last part of showing the view ps:it well be great if not needed android.permission.SYSTEM_ALERT_WINDOW

final WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
           WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                PixelFormat.TRANSLUCENT
        );

            params.gravity = Gravity.BOTTOM | Gravity.START;
            params.x = 220;
            params.y = 220;
            params.width = 220;
            params.height = 220;

// my view code 



        windowManager.addView(View, params);
J.Fort
  • 21
  • 4
  • Please clarify the task. Are you creating an [App Widget](https://developer.android.com/guide/topics/appwidgets/)? – atarasenko Oct 04 '18 at 21:40
  • no its a news rss app i need to show a small activity defiling rss content – J.Fort Oct 04 '18 at 21:50
  • It is possible to show activity that is not full screen https://stackoverflow.com/questions/1979369/android-activity-as-a-dialog. But when the user presses home button it will go to background. – atarasenko Oct 04 '18 at 22:08
  • It is also possible to show a dialog, it will not hide when home button is pressed. But while it is shown user will not be able to interact with other apps. Also it requires SYSTEM_ALERT_WINDOW permission. – atarasenko Oct 04 '18 at 22:10
  • ah thanx you , how i can call the activity from service please – J.Fort Oct 04 '18 at 22:23
  • To start Activity from Service, use FLAG_ACTIVITY_NEW_TASK https://stackoverflow.com/questions/3606596/android-start-activity-from-service. For communication of an existing Activity with a Service, use `bindService()/unbindService()` https://stackoverflow.com/questions/8341667/bind-unbind-service-example-android. – atarasenko Oct 04 '18 at 22:32

0 Answers0