Custom android launcher isn't immediately responsive to touch events - android

I'm building a custom Android launcher; at the moment it's pretty simple, it's a SurfaceView that renders a set of icons, and the app registers itself as a custom launcher using the manifest.
The SurfaceView is a custom class and it listens for touch events by overriding onTouchEvent. As I've tested my launcher, I noticed that if I quickly go to the launcher from an app ("press home", except its a gesture these days) and then press a button on the launcher, the touch event (I'd expect ACTION_DOWN) doesn't register. There's basically a tiny bit of latency before ACTION_DOWNs are properly propagated to the SurfaceView, after launching the launcher. I'd guess the latency is between 500ms to 1 second.
Does anyone know why this might be or how I could debug this further? It's a small thing, but it makes it annoying when trying to quickly change apps.

Related

How to avoid having the live wallpaper respond to touch events on recent tasks on Lollipop

Background
I've made a live wallpaper that can handle touch events .
The problem
There are some cases which I don't want it to handle touches (or listen to other events). This help prevent weird drawing and also save on the battery a bit.
For example, on Lollipop, I've noticed that when you show the recent tasks screen, the live wallpaper still has focus. This didn't happen on pre-Lollipop, because the recent tasks screen took over everything on the screen.
Another example is the wallpaper-chooser, even if you just show thumbnails of all live wallpapers, you would still show your own and handle touch events, as if the user is on the launcher.
However, when you show the notification bar or the menu of the launcher (by pressing the menu button), the live wallpaper will not get any touch events.
You can see those issues on other live wallpapers, like "Magic fluids free" for example.
Again, the problem is that on some cases, there is no way to disable the touch events, because you can't know when they happen (recent tasks and wallpaper chooser are such examples).
What I've tried
There isn't much to do. all of the methods of the Engine class failed to find the state of the sceneraios I've written about:
onOffsetsChanged, onVisibilityChanged, onSurfaceChanged, onSurfaceRedrawNeeded, onOffsetsChanged
The question
Is there any way to overcome this issue?
To stop listening to events in case the live wallpaper isn't on focus?
How about setting
setTouchEventsEnabled(false);
in your WallpaperService Engine class, when you don't want touchs to be handled, and set it to true when you do.

Is there a way to find out that the All Apps screen is shown?

I'm creating a live wallpaper for Android and ran into an issue with the manual scrolling (without using the onOffsetsChanged method). The scrolling works like a charm except for one, but very unpleasent side-effect - when a user opens the "AllApps" screen and this screen is semi-transparent (like on the Xperia phones), the wallpaper keeps on reacting the touch events when the user goes through screens with his/her installed apps and scrolls.
I understand that nothing is changed from the wallpaper's "point of view" if this screen is semi-transparent. It keeps on rendering and continues to process all the touch events.
So, the question is - is there a way to track down the moment when a user opens the "AllApps" screen and stop processing touch events until this screen is closed? Any ideas?

Play touch sound whenever the user interacts with screen

I want to play sound in android whenever user touches the screen irrespective of which app they are in. Like making it the UI touch sound. so that my app keeps running in the background and playing sound whenever user interacts with screen. where do i the code? what to write? pls help. This is for android. And i'm using eclipse.
This is not possible.
Android does not allow you to intercept touch events on the screen when outside your own app as this would allow malicious apps to take over all other apps and render the phone useless.
Furthermore, it would very quickly get annoying for the users, particularly if they're playing a game or something that requires a lot of touch events taking place.
I'm afraid it's impossible. You can intercept touch events only in your Activity.
Similar questions had been already asked
https://groups.google.com/forum/?fromgroups=#!topic/android-beginners/H45Xwm43NGQ

live wallpaper - detecting touches when navigation menu is open

I have a live wallpaper which responds to touch and swipe/move events.
If I press the applications button on my phone, I get a menu with all my installed apps. My problem is that when I scroll through my list of installed applications, it triggers the touch and move events on my - out of sight - wallpaper beneath. The wallpaper is still hogging resources drawing and updating anyway, and while scrolling through my installed apps, it can become slightly sluggish.
I was wondering if there was a way to determine if either: the menu is open, or preferably - whether or not the livewallpaper is actually visible or not.
EDIT - I can only think to listen for ACTION_MOVE events in WallpaperEngine. If you detect one without onOffsetChanged being called then you can assume the menu is open and disable touch events.

Any way to hide Android home screen icons to show Live Wallpaper?

As Android live wallpapers are becoming more prevalent, and developers are doing more with them, a question coming up more and more is how to hide the home screen icons temporarily while the user interacts with the wallpaper.
For this to work, the icons would have to be removed temporarily – not just made invisible, since a tap on an invisible icon would still run the app.
Also, it would be ideal to have a universal solution that works across customs launchers, not just the Android stock launcher.
This question was already asked on StackOverflow, and the answer was that you cannot do this. But this is clearly not correct, as there are at least two programs on Android Market that do exactly this: Show Off (Your Live Wallpaper) and The Cleaner (Show Wallpaper)
Is there a way to hide Android home screen icons, and then later put them back in place?
You can launch an activty which backgroung will be your live walpaper, and finish the activty upon touch... Just a thought...
Edit:
1st comment answer:
Preventing the delay:
You should be more "gentle" in the onCreate() method...
Try creating the minimum as possible in the onCreate(), like, just displaying the basic background...
in the end of the onCreate function, set an alarm (i.e. by AlarmManager) to call some BroadcastReceiver/Activity after half a second or so (with AlarmManager) to set the rest of the live wallpaper graphics... that way you don't have to worry about the delay.
This would have to be a completely new launcher. This is not possible without this I don't think. Sorry. However; to be absolutely sure though you'd have to look at the Launcher2 package in the android source and look through files like Homescreen.java. I'll look into it later on 2.3.3 for you and see what I find.
Try using the zoom gesture as you would to zoom in on a web page (reverse pinch). And you guessed it, the opposite makes everything come back.

Categories

Resources