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

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.

Related

Xamarin Back Button on Android Requires Two Clicks To Navigate Backwards

On Xamarin Android i have set in the App.cs the MainPage property to be a NavigationPage pointing to my MainPage.xaml page, which is a ContentPage. This navigates fine.
From a Command which executes from a Button in my MainPage.xaml I await a call to Navigation.PageAsync to go to my LoginPage.xaml, also a ContentPage. This works fine.
If i choose not to Login and wish to go back to the MainPage.xaml page from some unknown reason at the point where i was close to shipping it has decided that now it takes two clicks on the Android hardware back button to make this happen. This was not the case earlier in the day, it seems as if something has gone astray with Xamarin compilation as the only change i made was add some extra colors to a ResourceDictionary. This was working fine for months.
By the way, I have checked the NavigationStack, it is correct MainPage, and LoginPage (not two LoginPage instances). I also note RemovePage does not work anymore either, the point there being that if I do Login then i Remove the LoginPage so you don't come back to it from the following page.
In trying to find a cause I overrode OnBackButton inside the Android project and sure enough, the first click does not call it, only the second does. I have no idea how to fix this, my project was nearly ready to ship, and all of a sudden this. I've tried deleting the obj and bin folders and recompiling, Debug and Release, still the same. This is the case now on both emulator and physical devices.
Might anyone have an idea where to even begin looking how to fix this or better yet have a solution?
So i finally figured it out, and it is not pretty. I was wrong about only adding colours, i had also moved from a page a Style that works on TargetType Entry into App.xaml. In theory this should NOT have made a jot of difference, it would be just be merged into all the pages ResourceDictionary as per any other resource placed at the App.xaml level. I have two pages that had the exact same Style for Entry so i consolidated them at the root.
But here is the kicker. The double back button press comes about from one setter property that is there and only when it is in the App.xaml. I had set CursorPosition to 0. This innocuous setter causes the backbutton not to fire, no exceptions are thrown, just that it has this effect. Hope this helps someone.
P.S I'd have moved to MAUI (indeed did a full port) but that has so many issues relating to Images and crashing and performance at this time it is not possible, so stuck with Xamarin for now, fying pan or fire.

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

WebView shows a white page but events are working

When a webview is done loading it only shows a white page. The strangest part is that events (like a click on an anchor) are still working. After i perform this event and go back (with the back key), the webview is rendered correctly.
This behavior doesn't appear on a HTC Desire with Android 2.3.7, but it appears on the Asus Transformer Prime with Android 4.0.3.
If i put a Thread.sleep(10000) in onPageFinished() the page is visible for 10 seconds but then turns white, events are still working.
The Activity is the Launcher activity and extends a custom base activity. Every activity in my app extends this base activity. The base activity detects if a user is authorized and shows the login activity is needed. When i press the back button after the login activity is displayed, the launcher activity is shows the behavior as described above.
Don't know what to do right now to solve this problem...
The easiest way is to say that it is a bug in Android. But that doesn't solve my problem. Any suggestions to solve this case?
I have had the same problem for a couple of hours, what solved the problem for me was removing the setting below from my WebView constructor call:
this.setLongClickable(true);
I do not know why this worked.

Admob on Android - Status bar area not covered when activity is resumed

I'm experiencing very nasty bug trying to implement Admob in my
application.
I thought the problem is in my code, but after some investigation I
found it present also in Android-Banner-Essentials example (available for download here).
I wonder if anyone ever met this problem or maybe knows how to deal
with it.
Basically, when application has both status and title bar disabled, it
should use full screen.
Banner Essentials example displays nothing but Admob banner on the
very top of area available.
I downloaded the example, changed only two things:
added my publisher ID to compile properly and receive any ads ;)
added one param to activity's manifest to disable title and status
bar:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Compiled binary, no matter what device is it launched on (tried Nexus One, G1, Desire, different Android versions), is affected with the same issue:
When ad banner is displayed press Home,
Once taken back to home screen press and hold Home to see recently
launched apps,
Select back Banner Essentials app.
My tests reveal that with 50% reproduction chance Admob banner doesn't
go back to its position -the very top of the screen.
To show better what I mean I prepared three screenshots:
http://img841.imageshack.us/g/correctz.png/
Important notices:
When app is resumed normally, banner is displayed just below status
bar, and slides up until is aligned to the top screen border,
when error appears the banner doesn't move at all,
I couldn't reproduce the issue with any other interrupt (pressing
Back, Power Button),
I think it may be somehow connected to gaining/losing focus (see
screenshots).
My app is bit more complex than Banner Essentials so I started with searching the issue in my code, with no luck, thus tried to simplify the situation as much as possible and here are the results.
Does anyone know what may be causing the problem? Maybe some additional flags or properties have to be set to handle this behaviour?
This one is referenced as an Android bug. There is no solution, just a workaround.
You have to re-set Window Fullscreen about 1 second after onResume (to wait till the status bar finishes its fancy sliding out animation...), which will cause it to re/calculate the whole layout, "solving" the problem (with a quick jump to the correct positiin).
public void onResume()
{
...
handler.postDelayed(new Runnable() {
public void run() {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}, 1500);
...
}
It's not good. But it's still the best available. More info here.
In my case this behavior was triggered by resume from lock screen. No idea why but after adding empty overloaded function it was fixed (but I tested it only on my HTC Wilfire). It may be a different bug thou.
#Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
/* Workaround a probable Android bug with fullscreen activities:
* on resume status bar hides and black margin stays,
* reproducible half of the time when coming back from lock screen
* (tested on HTC Wildfire)
* No idea why but this empty overload method fixed it.
*/
}

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

Categories

Resources