Menu does not showup first time after install - android

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...

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();

android studio 2.2 layout editor refresh button

can someone help me find the refresh layout button which was there before studio 2.2 to refresh the layout changes?
Have searched every where but cannot find it.The problem is sometimes drawables are not refreshed and reflected in the preview window.
It's pretty simple to refresh.
Click on the preview screen, make sure that the preview window has the focus, and press R. It should display the progress in the top-right corner while refreshing.
If it doesn't work for any reason, switch to the design tab and press R. It refreshes the layout instantly.
I think it is a small bug, but I find a hack solution to resolve the problem.
You can change a resource id to a wrong name. For example, you have a resource named ic_launcher. When you input ic_launcher1, you can find the interface like this:
Next, click the refresh link (sometimes, it says 'clear cache').
I tried changing the orientation, but it does not work when I replace an existing image file.
Toggle the Orientation button in Editor, it is refreshing the changes.
Can't seem to find the refresh layout button too, it's as if it is deliberately removed.
However, I found a temporary refresh layout solution: On the screen orientation button, click the dropdown and then change the Night Mode. See this page for reference on where to find the screen orientation button. Hope this helps.
Close edited layout file and reopen.
You can do this with following shortcuts:
Ctrl+F4 (close tab)
Ctrl+Shift+E (open Recently edited files)
Enter
(select recent file to open, your layout file should be already
highlighted if edited last)

Android Launcher3 search bar not visible in landscape mode. Any suggestions?

I am using the Launcher 3 code as a base for building my own launcher application. I've managed to build everything correctly and import the project in Android Studio, however I seem to have some issues when switching into landscape mode on a Nexus 7 (first generation) device.
The problem is that at first the Google search and voice search icons do not appear but after pressing the home button they do. Also if you tap on the places where they should be, the search activity appears and when coming back to the launcher the buttons are there too. It seem that somehow they are not visible and I have looked over in the code but so far I could not find what the issue is.
Is there any one who encountered this problem and can point me in the right direction to solving it?
Thanks,
Mihai
I have managed to solve the problem.
It would seem that the drawableStateChanged() method from HolographicImageView is called when switching to landscape mode before the view is laid out. This would cause the mStatesUpdated flag set in the method generatePressedFocusedStates(ImageView v) in HolographicViewHelper to be set to true and the code updating the search bar ui would not be executed anymore in the subsequent calls of the generatePressedFocusedStates(ImageView v), after the view is laid out.
A simple check for isLaidOut() before calling generatePressedFocusedStates(ImageView v) in the drawableStateChanged() method would do the trick.

Android ICS widgets - listviews goes blank randomly (when launcher restarts?) RemoteviesService bug?

I've widget with listview inside and few times per day the listview items just disappears. I find out that it can be due to launcher restart - so I tried a little test. I manually restarted launcher, and it just confirmed my suspicion - it's definitely because of launcher restart.
How to deal with this? The rest of widget (buttons, listeners, ...) are working, just listview items disappear and I can't even see empty_list layout, that I defined - that's why i must add to my widget manual refresh button, but it's not very good solution...
The problem you are encounterung seems to be a known issue: see link here: http://code.google.com/p/android/issues/detail?id=28216
There you can find some workaround on how to fix this.
ok except that it's ICS bug, it's partially also my fault - just always recreate widget content in onUpdate method and it will be ok ;)

Spinner inside custom ListView freezes on returning from another activity

Hello all here is my problem.
My app's listview (which is inside a tab widget) contains various types of rows. I have had many problems setting this up and here is another 1. Please see here for the code, which basically remains the same.
I use another activity (a custom implemented ES file explorer) which is a filebrowser dialog to open a file. The data from the file is sent to the listview.
When it shows the list and I click on the spinner the screen darkens and freezes. If I press the back button the darkening disappears, the listview becomes clickable but the spinner still is not. The only way out is if I flip to another tab widget and back again (there are 2 separate ones) the spinner will work again.
I should say that the spinner works just fine if I do not load files from the other activity.
So I guess in other words there is a problem of focus or something when switching and killing activities.
I hope you can help.
EDIT
after some more trying, sometimes after loading the file from the browser it will return to a black screen where the listview is there but not visible.
eg you can click on it and the editor opens.
Hi well again it took ages but here was the problem.
the custom listview had
this.setDescendantFocusability(FOCUS_BEFORE_DESCENDANTS);
set
so all I had to do was set
holder.techniquespinner.setDescendantFocusability(parent.FOCUS_BEFORE_DESCENDANTS);
for the spinner and voila; I haven't tried but it should probably go in the xml file.
Thanks to anybody who looked.
EDIT
Crap I spoke to soon. It still doesn't work.
There is 2 tabwidgets inside a flipper.
If returning from the browser to the tab where it left WITHOUT flipping the flipper it works.
Flip once, back again and then to the browser does not work.
I'm not even sure what code to post. It is quite complex.
FINAL EDIT
This is how I fixed it.
flipper.showNext();
and then back again.
It somehow refreshes the view brings it back to focus and useable again.
It isn't pretty but it works.

Categories

Resources