Touch events happen befor an activity is displayed - android

In my program I have 2 activities. First one contains a keyboard for Pin and a second one which is displayed right after.
When an user enters 4 pin numbers second activity starts. But the problem is if the user clicks too many times on keyboard (more than 5 click), some touch events are propagated to next activity, while the first activity is still displayed.
This behavior is also somewhat device depended, to me it occurs on Asus Memo 10 tablet with Android 4.3, but it doesn't appear on nexus 7 with android 4.4.
Is there anyway to prevent click events being propagated to another while the first is still active?
And if that is not possible is there a way to detect when is activity is fully displayed so that I can disable click events until it is displayed.
Because I would really prefer not to have any arbitrary delay after pin input.
Thanks in advance.

onStart() method is what you're looking for to disable click events, but your aproach is not a good thing, maybe you should consider to have something like "Done" button, which user will click after he finishes his input? It can also be useful because you can write code to check pin for lenght or validate

Related

accessibility android Skip nav links are not working

I have added skip to main content links on header in my web app. It works as expected in Windows and MacOS. It even works as expected in IPhone. But the same is not working in Android chrome/talk back.
when I check further, This skip nav links are not working even in webaim.org . The code I refer https://www.bignerdranch.com/blog/web-accessibility-skip-navigation-links/
Could someone please help why android chrome is having this issue? Is it a browser behavior? Please help.
Let's analyze what is happening in this scenario.
1) TalkBack sets ACCESSIBILITY_FOCUS to the element
This is very important, notice that this says ACCESSIBILITY_FOCUSnot FOCUS. For a hidden skipnav link to become visible it needs to get FOCUS as marking the element as visible (or perhaps shifting it on screen) with the :focus pseudo selector is a very common implementation of this. It's very important that such a control receives FOCUS, which it never does with TalkBack.
2) The user double taps to click the element they just heard get focus.
When the user activates the control a physical click event is set to the middle of the onscreen focus rectangle for the control. Similar to actually touching the screen.
3) The browser sees a physical click event occur on the page.
TalkBack essentially has blindly sent a mouse down event to an area of the page that has nothing or perhaps another control overlayed with this invisible element. Either way, the thing that the browser wanted to click was never "visible" because it never properly obtained FOCUS only ACCESSIBILITY_FOCUS and so the control is not there to be clicked.

Libgdx InputProcessor - Determine if you swiped off of a keyDown

Working on a mobile game at the moment and was having difficulty getting the back button on android devices to function as I want it to.
Here's the scenario: You click down on the back button, realize you don't actually want to go back so you swipe up (while still pressed) onto the game screen, thus negating the back button being pushed.
I'm using InputProcessor and i have keyDown and keyUp. The problem is, i'm not sure how to use these two together so that when i swipe off the back button it doesn't go back.
I have been able to get the back button to do the other functionality i want (such as not exiting the app and going between screens and such), just stuck on this one scenario.
Any help is much appreciated.
Edit: This functionality can be seen in the facebook mobile app. If you click on the back button swipe off of it to the mainscreen, the app doesn't exit.
I don't know exactly the Syntax for Mobile development but I figure your best course of action is to create a Boolean willExit, and instantiate it as true, and in the KeyUp() function put and if (willExit) statement. Now you can have it run through the block KeyUp() without doing anything if willExit = false. From there you just set willExit to false whenever the condition is met, such as in your case when Swiping.
Simply in the KeyDown use the switch statement to see if the it is the back button or not.
If it is the back button, check if the screen is touched.
As simple as that.
BTW sorry for not providing code snippets.

Custom view like lock/unlock screen of android

I would like to create effects like lock/unlock screen of android. I have attached the screenshot here as well. In lock screen we have 2 buttons but in my case I am having 3 buttons and the middle button must be draggable.
The middle button can be drag to left/right.
I know I have to create custom view for this to work but I don't have any idea about how to drag button left/right with nice effect(animations) which normally any android phone have.
I need guidance on this, so can anyone suggest me how to approach for this.
Basically i wish to move/slide button left and right and based on that want to take some action.
I have tried making a lockscreen application myself and i almost made it, but here are the facts you will have to face at the end
You will not be able to disable home or menu button.
you will need user permission (not the one you get while installing the application, the menu pops up every time you press the home button unless the user decides to make your application default home screen, if that does happen you have successfully made a lock screen) if you decide to make a home screen application too.
the lock screen doesn't go very well with passwords
But if it helps, here's what i did:
You need to create a service that keeps a check on the screen being off and on.
if the screen is off, you do nothing. when the screen if ON you start the activity and wait for the user to do the thing you want the user to make him unlock the screen. and when he does that you finish() the activity.
While doing that you need to setup a method that can listen to check the incoming calls you can do that by extending PhoneStateListener and also disable the back button.
Good Luck and if you are able to make any further progress do let me know.
Maybe this project could help you GlowPadView. I've used it succesfully in one project. Hope it's what you're looking for.

Two-state button: Show current state or next state?

I have an action bar with a button to flip between two different views (list and tree). Should the button show (a) the current view or (b) the view that will be shown if the user clicks the button?
This is an age-old UI problem with no "right answer", only UI standards, so I'm trying to understand if there's any standard on this in Android.
I agree on the 'age-old' part. Myself I'm still questioning - when acting as a user, not a developer ;-) - what the button in front of me will do when I click it: turn on Shuffle or turn it of.
Now very pleased to come up with a feasible answer.
Since the user has a clear visual clue on the state the current presentation is in (List or Tree) the button would show the alternate option. Then the user knows that there is an alternate option and hopefully the button displays where it will take the user.
For more unclear situations I would still go with this approach. The user either knows or perhaps can deduce the current 'state' of the app ("hey it plays a whole different song now, so it is in shuffle"). So the button will bring me to another state, the one displayed.
Why display what the app is already doing and not displaying where a buttonpress will take the user?

Losing focus at buttons in android application

I made one simple android application and I notice next problem:
I have several controls with attached click (or i say touch) event (buttons, imageviews). Some of them are loaded from android xml file, and some I make "in fly".
Now when I scroll screen, I must 2 time click on button to make effect (click event). It seems to me that this have some connection with losing focus.
Am I right and how to solve it? I want just one click to execute some operation.
This happen only on real device (HTC Wildfire). In emulator there is no this problem.
Thanks!
Do you, by any chance, have
android:focusableInTouchMode="true"
for the Button? Because this will cause the button to need one touch to gain focus and another one to fire the click.

Categories

Resources