My initial question dealt with building a translucent view that allowed manipulation of a view below it. Bluefalcon did an excellent job answering this and helped me understand view mechanics a little better:
How can I interact with elements behind a translucent Android app?
I'm still unsure of how to manipulate an underlying view that is not part of my app. The effect I'm trying to achieve is like the Screen Filter App:
https://play.google.com/store/apps/details?id=com.haxor&hl=en
In this app, once started, it seems a "filter" view is placed on top of everything but you can still interact with whatever is running under it. The app store, email, home screen etc.
I currently have getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); in my app's onCreate method. This seems to get close. If I swipe on my app nothing updates, but when i back out of the app the home screen updates as if i swiped.
Any help will be greatly appreciated!
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 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 have read plenty of questions that deal with an app taking screenshot of the current users screen while the app runs in the background, but have not seen many articles that deal with the app taking a "screenshot" of itself while it runs in the background.
I would like this to be able to be done without having to root the phone in any way as I would like the app I make be available to everyone(rooting is probably not involved in this solution, but just throwing that out there).
The end goal of the app is for the app be able to take a screenshot of itself and save that screenshot as the users background wallpaper. There are several other features I would like to add, but I would just want to know, is this even possible? If this is, could anyone show me some starter code or link me to some?If this question has been asked before, please let me know, otherwise, any and all help is appreciated. Thank you!
Firstly, I am not really sure if I understand your requirement correctly. Ideally when the app is in background, its state when it went to the background and while it is in background will remain the same. So you can take a screenshot of your app, when the app is just going in background, which can be handled in your onPause() of the activity.
To take screenshot of your app, place the entire layout in a ViewGroup and then use the following code.
parentLayout = (RelativeLayout)findViewById(R.id.parentLayout);
parentLayout.setDrawingCacheEnabled(true);
parentLayout.buildDrawingCache();
And when you want to take a screenshot, get the screenshot in the Bitmap by using
bitmap = parentLayout.getDrawingCache();
The above line should be in your onPause() thats when the app goes in background. Or you could also trigger it when your app is in background, and see if it is captured. I'm not really sure how it will work in the latter scenario.
I've been building for Android for six months now, and I'm still confused about how things happen in the UI. When I learned iOS programming, the books and docs were very clear about what happened when: for instance, that view changes and animations didn't take effect until the next iteration through the run loop. This understanding is critical to debugging UI glitches, and without it I'm having trouble tracking stuff down in our Android app (http://emu.is/download/).
For instance:
We had a situation where pressing a button brought up a fragment, and also displayed an animation as feedback for the button click. I started the animation before pulling in the fragment, yet it didn't actually run until after the fragment appeared. Why?
Often, opening a new Activity will take a long time, during which the user doesn't have great feedback that anything is happening. I'd love to pull up a minimal container for the Activity, then load its content, so the user knows what's happening. How do I do that?
Sometimes our chat bubbles (which are drawn programmatically via a custom Drawable) flash a bit, and it looks like they're being rendered halfway through their drawing process. Why? How do I avoid that?
And so forth. Basically I'd like to understand as much as possible about what happens when in the Android UI -- not just the lifecycle stuff that's well-documented, but the relationship between various UI calls and when/how things actually happen onscreen. Thanks.