I was wondering if it was possible to remove a floating View using TYPE_SYSTEM_OVERLAY used by another App (I'm thinking about Facebook Messenger among others).
I firstly tried to display my own overlay with transluscent background, thinking that it would probably take the other app's place... but sadly the 2 are coexisting (it's interesting to see that many apps can bring their view to the "top most" level).
So at the end: is there any way to get rid of those views ? (I'm working on an app that will allow users to enable a kind of no-distraction mode) - or do we have to live with it ?
Related
How can I have PiP mode while I am still in the App?
I am creating a video calling App, and while the call is still going on, you are able to go to a separate full screen view that currently is the same Fragment with the views being hidden/shown. When I go to separate full screen view, the cameras are no longer visible. We would like to solve that issue by putting the cameras in PiP mode. I see that the google meet app does that. But I could not find any reference to how to do this on the web.
Example of what I am trying to do:
Android does not provide native solution to this problem. Instead I used a touch listener to listen for drag and drop events my self. There are multiple tutorials on this topic.
I was looking for some auto event capture for every screen and button clicks without manually putting them on every single button or Activity/Fragment and I could find few. But I am really curious to know what to going under the hood and how are they getting these info about screen views and button clicks.
Looking for some tips to create my custom auto capture events in Android App.
You just have your tracking logic in global screen renderer, or button click listener, using whatever available there (screen ids, button ids, class names) to put in your events.
However, this only works if you don't hack around and always use the same methods for rendering and navigations.
Soon enough, the product owner will ask you to make a transparent screen, or to have a screen that flows from right to left, or a screen that opens only to a 1/3 of the screen, or a pop-up, or an overlay, or a weird iframe. You'll have to have defined tracking for those separately.
And then, on top of that, the Analytics team will donate their bit of discord where they don't want to see transparent screens as new screenviews, but also track red buttons differently from green ones. And Toggles should be tracked differently too. By the way, the screen class names aren't useful for analytics, please name them manually. And also, buttons that look like links should be tracked this special way. And don't track the buttons that are just tooltips. Oh, the iframes. The iframes issue messages on activity in them, so listen to those and translate them to events please.
Now, this is an example of what it's going to be like. In real life, it's even more than that. If you have to add an exception for your universal tracking every time Analytics doesn't like it, you will end up with a mess of nested logic that is impossible to maintain. Also, every change to it will cause more bugs in unexpected places than fixes.
Still, universal tracking makes sense when you don't have dedicated analysts or a large marketing team and so you don't want to be able to answer complex business questions frequently.
In all other cases, it's better to hardcode analytics in a structured manner, maybe mapping screen ids to screen names in one neat place, then have analytics sdk wrappers to store the core logic and make use of the name mapping,
I am customizing an NXP based Android 10 BSP on an iMX8 platform and I'm trying to make a custom swipe up bottom sheet that's global to the OS like the status/notifications bar on a swipe down gesture.
I've followed this thread here but customized the swipe up layout to have a list of applications available on the OS (basically a launcher within an app).
While this feature works great within my app, I actually want that slide up layout to be global so that I can launch applications no matter which card/application I'm currently on.
How would I go about doing this since this feature is limited to my main app? Would it be possible to add this to SystemUI?
Yes technically, you can do something like the existing NotificationBar that you can drag from the top of the screen. In your case you'd do from the bottom.
The logic for NotificationPanelView is in SystemUI package.
But beware, the existing logic there is a bit spaghetti code, so it could take a while to understand in order to add your own panel.
Another option for you would be to have your panel as an overlay view on top of everything ( drawn from a background service from your app ). See this answer for some initial guidance.
You'd show at first a transparent view, that receives all inputs. If you detect the gesture, you 'move up' the sheet from the bottom, otherwise you pass the input to apps below.
Note that this:
Would mean your service needs to be a foreground service, so its not killed.
If your app is killed from Settings, the BottomSheet will go away as well.
You cannot show this over the Settings app ( intentional Android limitation)
To recap:
The SystemUI solution would be better long term, less limitations... but more difficult to develop initially.
The App overlay solution is easy to implement, but has several limitations which can be a dealbreaker.
I have an overlay View that I attach directly to the WindowManager as described here: How is Facebook Chat Heads implemented?.
I would like this overlay View to be partially transparent and allow touchEvent to go through (so that users can interact with the Android UI below).
Is this somehow possible ? I'm guessing there might be some security considerations here but haven't been able to confirm this anywhere.
I would like this overlay View to be partially transparent
That's fine — that's merely a matter of what your View is (e.g., background).
and allow touchEvent to go through (so that users can interact with the Android UI below).
Fortunately, that is not possible, for obvious privacy and security reasons. What you are describing is called a tapjacking attack. Only one app gets the touch event, so if you get the touch event, your app consumes it.
Actually you can use a library called standout to have your app overlay the screen.
Standout Library:
https://github.com/pingpongboss/StandOut
Should jump start you on your project!
I went through some posts, but most of them discuss placing a image or a string with information on it.
I however need to place button that manipulates some call features.
Is there a method to do that universally works throughout all android distributions?
(I thought to pop up custom screen with my button above usual screen. Is that good idea, or is there more straightforward way to achieve this?)
Thanks a lot
On stock devices there isn't going to be a legit way to put your own button "on" any portion of the Dialer application Activities (including incoming call screen). This kind of functionality would require the Dialer to explicitly provide an API for it. The stock system prevents applications in the background from placing their own clickable regions "on top of" whatever is currently in the foreground . (It's a good thing too, the bad reasons to do this far outweigh the legit ones.)
If you are wanting to do this you're going to have to look into building your own version of the OS that allows for it. OR potentially if you unlock your device enough to be able to install your own application that handles all of the functionality of the Dialer. Then you could provide an API for a third party application to do it(or just "bake in" your button to the Dialer) But I imagine that being able to get it all hooked up correctly to actually make your calls would be mighty difficult.