Appium press call back button make the app crash on android - 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();

Related

What is good way to backtrack a function in your Android app (like a button) to the code that implements it?

I have a project that I did not develop but am trying to fix bugs in. There's a button that I press and then a bug occurs. I want to find out where in the code this button is implemented but its hard to trace it since there are so many classes and layout files. Usually, if there's text associated with the button, then I find the string in my strings.xml file and work my way back. Unfortunately, this button doesn't have any text associated with it.
Hey just connect your actual android phone and run the app on it and also open logcat, when you will click that button logcat should hopefully display all the errors and you can go to the function.
Try this and comment me back if it works
This is a unconvential method, but I used it in the beginning aswell. In Android Studio press CTRL + H to open the Find in Path dialog. This will search the whole project.
For a Button you might want to search e.g. setOnClickListener, Button etc. and navigate it down by this approach. This method will also find dynamically created Views in case it's not in the layout.xml

"Fire" in the Android Jetboy Example App

I'm testing the "Jetboy" example Android code in an emulator. It says "Use your fire button...". Where is that? I've clicked all the buttons on my mouse, and hit about all the buttons on my keyboard, and I get nothing.
I was hoping that the following link would help, but I don't see my particular need in it:
http://developer.android.com/guide/developing/devices/emulator.html
Thanks for your help!
You can find the relevant code inside JetBoyView.java, check the processKeyEvent() method.
Fire is the DPAD center, thats usually pressing the trackball/-pad on a device. On the emulator it's this button:

Menu does not showup first time after install

i a facing very weird problem in my app. i am inflating a layout on pressing menu key. and setting that layout on popupwindow. the prob i am facing is that when i install build on device and press menu key, popup does not show up. but if i navigate to some other screen and come back to previous screen, menu key works perfectly.
even if i cllose app and open it next time, menu key works fine. it does not work for the first time after install.
thanks in advance.
Maybe you set your click listener for the menu button in the wrong lifecycle method? Perhaps it doesn't add the listener until after onPause()? Seeing some source would be very helpful to be sure.
I think android pretty much decides on its own when it updates its layouts and redraws the view. Maybe your newly inflated view doesnt affect the other layouts in a way that makes this seem neccessary. I would try to call requestLayout()/forceLayout() on the main layout...
Not sure though...

Back button Wont work

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

the application has stopped unexpectedly

I have built a game. When the user clicks a button on the main page, he is redirected to another activity for a predefined time(say 20 s) and then he returns to the main page where he can choose another button. Now, this works perfectly on the emulator but on the phone when I clicks another button on the main page, it says the application has stopped unexpectedly. Force close. However, if I wait for say 3 s before clicking another button, it works. Is it because the images on the background of the buttons are too heavy?? Kindly help. Thanks in advance.
hey! i found out what was wrong. There was one picture which was too heavy!! it works fine now :)
Sometimes this error results from the widget like textview and so on, please delete the line related to something like textview.

Categories

Resources