Back button Wont work - android

I have created an app using appinvintor. The problem is when i hit the back button on my android it closes the whole application i just want it to go to the previous step or page, how would i code that

Currently you can't do that because right now we are given only one screen. But you can manipulate like this.

since beginning of 2012 there is the multiple screen feature in AI and now it is possible to catch the back button, see this example http://puravidaapps.com/backbutton.php
Taifun

Related

Appium press call back button make the app crash on android

I have searched the same symptom but cannot be fixed.
I use appium to do some automation with UiAutomator1.
Every call the back button
driver.keyevent(4)
The app crash(or exit) and goes to the Android home page.
The log seems normal.
However, a click back button on the emulator is fine.
There is no way to go to that page without click back button.
How can I click back button, or get the view name and go to that view directly?
Thanks.
If you want to click on BACK button in android, I think the following code will work fine:
driver.pressKeyCode(AndroidKeyCode.BACK);
reference:
http://appium.io/docs/en/commands/device/keys/press-keycode/
I don't know how to fix it.
However, i use another way to fix my problem.
self.driver.start_activity("xxx", "xxx")
It may not the best solution, but it can go to the view directly
Got the same problem some time back, solved using this :
driver.navigate().back();
or you can also try using this :
driver.back();

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.

How to build a random button picker with the blocks in app inventor 2?

I am a beginner and I don’t have any experience with coding etc. and I need help
The first screenshot:
shows my screen, and as you can depict from it there are two buttons- the first one is called RIGHT BUTTON, and the other one is called WRONG BUTTON. This is because clicking on the RIGHT BUTTON will open a next screen, whereas clicking on the WRONG BUTTON will result in going back to the previous screen. I thought that this is kind of boring :D that’s why I want to build something with the blocks that would choose randomly one of those buttons to be right and the other one to be wrong after the screen has initialized. To make it more clear. Every time I start the app I don’t know which button out of those two will take me one screen further- it could be the first or the second button- I want this to be a random pick.
Now, I have tried to build something like this blocks:
but I can’t find a suitable block, as you can see in screen shot 2 :D I assume, that this isn’t the way it should look like, but my skill is too low at the moment. I also assume that I will need an "if,then" block" I would be really grateful if someone built it and made a screenshot and post it here ;)
Basically, I am kindly asking for help. I have been looking on the internet for a tutorial etc. but I couldn’t find something that would really help me.
Thank you very much in advance ;)
When the button is pressed, instead of opening the next/prev screen, instead call a custom procedure and have that procedure decide if it was the right button to press or not. This can be done several ways, for instance with the Math.randomInteger block. You don't actually have to decide if it was the right button or not before the button is pressed, just do a "coin flip" at the time of the button press to decide (at least that's what it sounds like you wanted from your description).
Also note that the number of screens in AI is highly limited, and instead of going to another screen, you can just reuse the same buttons over and over (and maybe just show a label in the corner counting how far you've come), or make lots of buttons and only have the first two visible at the start, then as you progress hide/unhide the correct buttons.
Here this is the answer I have found for my problem using your info

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.

return back to previous activity

i am doing a search results and once I click on the results, it will display the details. After I click on the back button, it should display the searched results I have done.
E.g.
When I click "back" on image 3, it returned to image 1 instead of image 2. Is there a way to solve it? I simply just did finish(); on image 3
You need to intercept the back button and control the flow of your application. DO NOT use state variables, avoid this approach as this can lead to more unstable problem UNLESS you design your states very carefully and have your states defined WELL. Try to learn the control that is available in the android framework.

Categories

Resources