Touch on multiple ActivityViews in Android11 - android

how can i use multiple ActivityViews correctly in Android11?
I already created a working sample in P+Q. But in R touch stopped working. The activities are displayed well but only the highest view reacts on touch. All other activies do not respond. If i reorder the views during runtime, the new highest activity becomes interactable. The other views will again not respond.
After a lot of testing i saw, that those ActivityViews which are not interactable, will receive touch events if i add a corresponding listerner inside the hosting app. Strange is that the view which is working well, will not get any event. I assume that the touch is redirected through the virtual display to the hosted activity directly. But i dont have a proof.
How can i make all hosted activities interactable? Since i have system access, i am fine with accessing hidden APIs. Unfortunately i cannot find which change in R causes the issue. So at least hints where to search would be helpful because i am running out of ideas.

Related

In Android, how to display a StatusBar/View to be used in multiple activities?

Android newbie here. I have an existing legacy app in Swing that I wish to convert to an Android App. In the legacy app, I have a permanent StatusView in the bottom (outlined in yellow). The StatusView will remain displayed all throughout the application.
More background info.. The android application, an in-vehicle asset management terminal, will be a bit complex as it has a lot of Activities and background threads involved. On application startup, it will connect to our backend thru socket based communication. The StatusView needs to display an image showing it is COMMS CONNECTED. Also, on application startup, it will show if it is GPS CONNECTED.
In Android, how will I accomplish this? Will it be a fragment passed to each activity? Or will it be just a custom view created or passed on each activity? Is this possible?
If it's not a complicated app i.e if there is no real need to have multiple activities, then i would definitely recommend using a view in your xml layout for the status information and use fragments for rendering other pieces of information around your status view.
If you absolutely can't do the app with one activity, then i think you will have to create a fragment for your status information and then attach it to every activity. Remember that the fragment's lifecycle is connected and controlled with that of the activity it is attached to. So, you will have to attach/add your status fragment for each activity.
Hope that helps.
Just create one view for that and use <include ... /> to include that view to your Activity's layout. In each Activity you have to modify it independently.

Track all UI clicks in Android application

I'm writing the library for Android apps which will report all crashes to the server.
I need to report the last user clicks or user interactions with the app before the crash.
So the question is - Is there anyway to track all the clicks in whole android application?
In my library I have only Application instance.
I am not sure its possible to catch all UI clicks. but you can make the developers add code to specific actions that will track this. like have your implementation of the onClick Listener, on touch listener that developers will extend to use with onTouch, on click.
Other than that i don't think its possible apart from adding a container view that will intercept all touch events as the root view.
For instance. you can provide extended basic components such as FrameLayout, RelativeLayout etc.. which override onInterceptTouchEvent and track the events there. The developers will use your layouts for the root views for each of their screens.
Having a global touch handler which you would just plug into the Application class is not possible i believe. Java enables you to set default exception handlers as ACRA and the others do for this purpose.

ViewFlipper in AppWidgets and Don't keep activities

I am trying to implement a Appwidget using view flipper. I declared two views in my view flipper and everything working fine. Now from developer options select "Don't keep activities option" and come back to home screen. You will find appwidget with viewflipper is hang.
Remove appwidget from screen and resinstall. It will start workin normally till you are on home screen. Launching any activity will result in same problem. Your appwidget stop working.
From the logs there are nothing coming to your appwidget provider. Every time we launch any activity Home screen activity get killed.
This problem happens every time with ViewFlipper in particular.
I am really frustrated, with every new release Google adding more instability. Android should decide either handle activity cycle OR simply handle it like iOS.
If any body able to get around this problem with View flippers on Appwidget please enlighten me. Or If anyone think better not use viewflipper on appwidget , please share.
Oh! this is my problem, I thought I just wasn't handling low memory situations with the appwidget id's correctly
this app uses viewflippers on a widget https://play.google.com/store/apps/details?id=co.ccltd.maplights.nyc.freemium&feature=nav_result#?t=W251bGwsMSwxLDMsImNvLmNjbHRkLm1hcGxpZ2h0cy5ueWMuZnJlZW1pdW0iXQ..
what I did increase the widget update time, which is now 30 minutes. for my particular application this is adequate. Basically it the viewflippers and pendingintents will hang after android deprioritizes it (won't even be able to get a response after a click), but after the widget updates it will be working again.
or so I think, more testing is needed! but its good to know that its not only my handling of appwidget ids in low memory situations, but possibly a glitch

How to implement multiple screens within an App

I am currently working on an Android App which has different service dimensions, such as " service order", "route planning", "photo gallery" and a central login.
so far i implemented each "screen" (and by screen i mean actually the layout of a screen) as a seperate class, which loads a specific layout and handles all listeners and core functionalities such as calling webservices in a thread, receiving answers etc.
I am not quite sure if this is the best way to implemnt mulitiple layout-screens.
The Android dev guideline proposes to use single activities for each "screen layout". However I doubt that this is the most effective way of doing things. Since i need information for each "layout" which are retrieved by the central login (here: a user object). Since an activity (as far as i understand) is a seperate thread, the passing and retrieving of information seems not very practical.
I would like to get your oppinions/feedback on that and thanks for any hint or tip.
So far my structure looks like :
Activity
loads login layout (res/layout/login.xml with setlContentView)
depending on buttonclick other resources are loaded and initialized (means listeners are added etc.)
Greets
Peter
The dev guidelines recommend that for a reason. It IS the most effective way of doing things. You may complain about having to store your data so it can be passed along from activity to activity, but guess what? You're developing an app for a phone! At any point in time, the phone could ring, forcing the user to switch away from your app. Or the user could just choose to temporarily look at a different app. If your app goes back to square one after switching back and lost all data, the user will be understandably angry.
Don't know if this would be suitable for your app, but another option could be to split off the core data handling into a Service, and have your app be just a UI frontend which communicates with that service.

Getting touch event in any view (Android)

I need to make a service that capture all touch events, not in a specific view or when an specific activity is open. This service is started when the boot is completed (and I have an app to stop/play this service when I want it). So it write something (in a Toast) when the user touch any place in the screen.
Can I do this? Or only in specifics things (with OnTouchListener and adding specifics views, for example)?
Sorry for my bad english.
thanks
If you override the View itself and build your own ROM, you will be able to have these kind of things. So, straight answer will be just no. Sorry.

Categories

Resources