android


onCreateView is called after returning back from second activity


I have MainActivityFragment from where I start DetailActivity with below code:
private final CurrencyListAdapter.ClickListener itemClickListener
= new CurrencyListAdapter.ClickListener() {
#Override
public void onItemClick(int position, View v) {
Intent intent = new Intent(getActivity(), DetailActivity.class);
String code = mCurrencyList.get(position).getCode();
intent.putExtra(Constants.SELECTED_CODE_KEY, code);
startActivity(intent);
}
};
After that from my DetailActivity I start my DetailActivityFragment with below code:
if (savedInstanceState == null) {
DetailActivityFragment fragment = DetailActivityFragment.getInstance(code);
getSupportFragmentManager()
.beginTransaction()
.add(R.id.detail_container, fragment)
.commit();
}
Also I am retaining the instance state within my MainActivityFragment. However, while hitting back button from DetailActivityFragment, onCreateView method of my MainActivityFragment is called and I am not able to restore instance state, because saveInstanceState method is not executed and thus the savedInstanceState is null.
I am very curious why this happening. This is not happening in other project wich has the same logic. I will be very thankful if anyone could help me.
I have already figured it out. I was loading MainActivity through xml layout file. I changed this and included the following code into my MainActivity and after the issue is gone:
if (savedInstanceState == null) {
MainActivityFragment fragment = new MainActivityFragment();
getSupportFragmentManager()
.beginTransaction()
.add(R.id.main_container, fragment)
.commit();
}

Related Links

Android - ListViews inside tableLayout
How to add check box counter android eclipse
How can my apk be self-installed from website without an SD Card?
Android, layout screen width
AsyncTask inside a Static method - Good Coding Practice?
Is there a programmatic way to update an android app on the android market?
Calling a native method from Android project
How do you save the data of an int, and then edit the number onclick of a button?
connect activitys
mixing SQLite DB and GetSharedPreferences()
Android Couchbase - URI for attachments
Trying to use Toast message, but get error
How to deploy android plugin that can be loaded from my application
Display Android Preferences in Different Units
SOCKet Secure (SOCKS) server for Android
Android: NullPointer Exception on recreating the alarm on OS Bootup?

Categories

HOME
ggplot2
webdriver
google-spreadsheet
jelastic
oracle-apex-5
r-googlesheets
cq5
polling
frontend
sendgrid-api-v3
spin
vimdiff
java.util.logging
alamofire
cmdb
datastage
ipmitool
php-5.6
tput
stellar.js
gkturnbasedmatch
flash-player
coin3d
vuejs
smartclient
windows-xp
href
roslyn
exit
jboss6.x
mount
maze
angularjs-components
oculus
exchangewebservices
quantlib
tizen-tv
calculation
dst
deltaspike
quickfixj
angularjs-material
hibernate-validator
carriage-return
python-import
python-pptx
openproject
password-protection
visa
android-ibeacon
facebook-social-plugins
opencmis
x++
plan-9
term
rserve
payara-micro
context-sensitive-grammar
boxing
materialized-path-pattern
taocp
mapxtreme
pacemaker
preprocessor
file-uri
ng-grid
observablecollection
refinerycms
android-wake-lock
database-relations
beanstalk
lazybones
django-urls
binomial-theorem
sony-lifelog-api
vacuum
matlab-deployment
uvc
execve
android-vibration
filesplitting
spy++
insight.database
matrix-inverse
wxformbuilder
drupal-nodes
git-repo
tlf
nevron
route-provider
actiondispatch
android-icons
swfobject
monotouch.dialog
boost-msm
rmiregistry
extconf.rb
lambdaj
oracle-enterprise-linux
cgimage
mysql-error-1205
entitydatasource
tournament
cac
ruby-1.8
instantiationexception
aspmenu
django-piston
data-mapping
product-management
movieplayer

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App