3

In iOS there is a UIWindow which we can use to keep a view in front of everything (all view controllers). I am trying to find a similar way in android.

I have a Main activity with a sliding tabbed view pager with 3 fragments. The Main activity can show another by calling startActivity on an Intent of another activity (sorry if I am not using the right words, still very new to android).

I want a View to stay in front of everything. So even when mainactivity shows the other activity, that view should still stay on screen at the same position. How can I achieve this?

In iOS this is as simple as adding that view to the UIWindow. Is there something similar in android?

Similar to the Youtube app where the player stays in front even when you click on a channel name to go to another detail activity.

2 Answers2

1

You can use a service and the android.permission.SYSTEM_ALERT_WINDOW permission for overdrawing in front of everything (even when your app is closed). Then you can use this service and start and stop it when you need. For more information and an example, you can follow this link:

http://www.androidhive.info/2016/11/android-floating-widget-like-facebook-chat-head/

which is not exactly what you want, but it overdraws inf front of all applications and I'm sure that you can use it in your case with some modification.

However I think the best way for achieving what you need, is using fragments.

A. Badakhshan
  • 1,045
  • 7
  • 22
0

You can use AlertDialog or DialogFragment OR PopupWindow. It will create a windows on top of your screens in your app. These windows are limited to an app in which these are added.

1. How do I display an alert dialog on Android?

2. Dialog Fragment detailed example

3. How to make a simple android popup window?

Community
  • 1
  • 1
PEHLAJ
  • 9,980
  • 9
  • 41
  • 53