Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an overlay when sharing into app in android?

I am working on an android app that receives content from another apps sharing it via an android intent. I did the intent filter to receive the shared content into the app, but I saw that apps like Pocket made that without leaving the original app with an overlay over the app and I don't know how to do that. Does anyone know how to do that or give me some hints?

enter image description here

like image 949
jesusbotella Avatar asked Nov 23 '14 01:11

jesusbotella


People also ask

What is app overlay Android?

As a key UI feature of Android, overlay enables one app to draw over other apps by creating an extra View layer on top of the host View. While greatly facilitating user interactions with multiple apps at the same time, it is often exploited by malicious apps (malware) to attack users.

What does it mean for an app to overlay?

A screen overlay in Android, also referred to as “Draw On Top”, allows an app to display content over another app. The Android app permission SYSTEM_ALERT_WINDOW makes this possible. If you've ever used an app like Facebook Messenger or Lastpass, you've experienced screen overlay in action.


3 Answers

Start activity that has transparent theme with following attributes (test this on API 18 for bug):

<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>

Set child elements as you desire, as you would do in normal activity.

like image 62
Nikola Despotoski Avatar answered Sep 29 '22 19:09

Nikola Despotoski


After receiving your Intent, you should start a Service which create and attach your View/ViewGroup on the Window. This will allow you to keep the calling application in foreground.

To create a floating overlay take a look here: http://www.piwai.info/chatheads-basics/

like image 37
bonnyz Avatar answered Sep 29 '22 20:09

bonnyz


I would look at the WindowManager Class:

http://developer.android.com/reference/android/view/WindowManager.html

Here is a link to a question that better explains what it is:

What is WindowManager in android?

like image 28
BlackHatSamurai Avatar answered Sep 29 '22 19:09

BlackHatSamurai