In android 4.4.2 Activity resuming loads the default fragment - android

In my app i have noticed a strange behaviour in android 4.4.2. I am using a Sherlock Navigation Drawer to show side drawer and replacing fragments to load differnt pages within the same activity.But after minimizing the application and relaunching in android 4.4.2 its loading the default fragmant but in other versions of android its resuming to the fragment from where i left. I have tested with the versions 4.2.2,4.1.2,4.0.2,2.3.3 and its working as i expected and the issue occurs only in android 4.4.2
any help is appriciated....

I think for this reason you are facing problem in 4.4.2 just check the reason is, that the creator of ActionBarSherlock, Jake Wharton, announced on Google+ that further development of ActionBarSherlock has been stopped. ActionBarSherlock 4.4 is the last release and might get bug fixes – but there won’t be any new features:
While there may be a dot release or two in the coming weeks, version 4.4
is shaping up to be The Last Release.
For more please check the https://www.grokkingandroid.com/migrating-actionbarsherlock-actionbarcompat/

I don't know why this may happen but you can do some precautions to avoid this. Save the current active fragment position in a SharedPreference or inside onSaveInstanceState method and inside onResume() of your activity check if it is not the currently selected, replace it.

Related

lifecycle-process: app crash when importing dependency

I was using lifecycle extensions library for a while, but I notice that when updating from 2.1.0 to 2.2.0 the app crash systematically when opening a draggable view. Since the library has been reworked, and the code I use is now in lifecycle-process. But even with the latest alpha version (2.3.0-alpha07) the crash is here. The crash only occurs on API 29 and above.
I've a legacy code for a draggable view that creates a fragment transaction on the pre-draw of the Activity. If I don't add the lib dependency the Fragment is Resumed on the Activity pre-draw, when I add the lib dependency (even if no code used) the Fragment is only Initialized on the Activity pre-draw.
I understand the lib ContentProvider starts even if I don't need it, but I'm not sure what is causing this Fragment lifecycle change. I found that the ReportFragment has worrying comments and a API>=29 check, so if you can help on that, thanks!
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:lifecycle/lifecycle-runtime/src/main/java/androidx/lifecycle/ReportFragment.java;l=41
PS: If I use commitNow instead of commit in my DraggingView, I don't see the crash anymore. But I want to understand that to be sure it's ok in the rest of my app.
PS2: I tried to create a SSCCE but I cannot reproduce the issue outside of my app, and I can't share my entire app :/

Layout broken by instant app API?

I am working on an instant app demo app. I used the default template which I extended with a RecyclerView and a custom adapter. My problem is that my layout is totally broken:
As you see the toolbar is the same, but something does not work correctly regarding the coordinator layout. The floating action button is missing and the navigation drawer is not displayed below the system UI (the notification area) and yep of cause the menu is empty.
The both screens are debug builds so proguard is not messing anything up (I got also release working with proguard, but of cause I still have the same issue). On the left is the result of the gradle task :app:assembleDebug and on the right :instantapp:assembleDebug.
Since I use except of the recycler view the default template for this app I add no code, any idea why my layout is broken in instant apps?
Please follow these steps and you should be good to go!
https://developer.android.com/topic/instant-apps/getting-started/first-instant-app.html
Note : Please select Navigation Drawer Activity in Step 8
From the shared image, it looks like you have modified some code from the default Navigation Drawer Activity for your IA. If yes, please share the code to investigate.
Also, let me know the device/emulator and the Android studio you are using. I was not able to reproduce the issue with Studio version 3.0.1 on Nexus 5x (Android version 8.0.1). Following is the image of the instant app from my nexus 5x with 8.0.1 build. Let me know if I am missing something!

Android Studio create new activity requires fragment

I have been away from Android app creation for quite a while and has just recently begun my new App.
Now i thought i would test out this new Android Studio and therefore downloaded it.
When i started my project it asked for a fragment and i wasnt quite sure what it ment (i know what a fragment is!).
When it started the project i had a activity_main and a fragment_main. And now every time i want to create a new activity it requires me to create an additional fragement.
Can anyone explain to me why this is happening (maybe ive missed something).
Fragments are part of Google's UI design philosophy since Honeycomb (see embedded link).
If you would like to work around the default activity template in Android Studio, then check out this blog post.
To add an Activity without a fragment, select File->New->Activity->Empty Activity

Android- bottom bar tab

Need to create an application in a below mentioned link format targeting all the android platform i.e. from 1.5 to 4.1
http://natieklopper.blogspot.in/2011/08/iphone-styled-bottom-aligned-tab-bar.html
Can I use tab activity class for the same? Know it is deprecated but still need to confirm if we use then will my application work on all android devices.
Not getting appropriate demo or example to start my application with fragments,action bar sherlock's tab.
Please suggest me a simple way to initiate my application. Really appreciate if some examples are available.
Your application will work in all android devices if they have a newer version than 1.5
Deprecated means obsolete, but you can continue using ;)

java.lang.IllegalStateException in Android 3.x and 4.x ; Works fine on 2.x

I am using TabActivity which contains Four tabs. For every tab I am using ActivityGroup and inside ActivityGroup I have several activities. In one of my Activity I have a Google Map. Whenever I click on the built in Back button in Google Map Activity I am getting the below Exception.
android java.lang.illegalstateexception can not perform this action after onsaveinstancestate.
I am getting the above Exception in 3.x and 4.x Android versions. But in 2.x it is working fine without any Exception.
Please post your code. Otherwise, no point of discussion.
As far as I know, you may pass wrong parameters or using the same API twice.
are you using startmanaging cursor anywhere in the code for this activity.
This works fines for 2.3 OS but 3.0 onwards it throws error. I also faced same situation, the way to resolve is the add startmanaging cursor only in 2.3 below OS.

Categories

Resources