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?
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.
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.
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.
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/
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With