I am new in Android development. I want to develop a questionnaire. There are only two activities in questionnaire Main activity and camera activity. in May Main activity I have ListView
with ListView.CHOICE_MODE_MULTIPLE
.+ two text field for latitude and longitude. when user give Right question i checked check box grammatically. When all Question Checked then User can capture photo so i start Camera activity on button click like this
Intent cameraIntent = new Intent(myContext,MyCAMERA.class);
startActivity(cameraIntent);
When User Confirm Photo i start Main activity gain as follow
Intent mainIntent = new Intent(this, MAINActivity.class);
startActivity(mainIntent);
When I start back main activity as mention above my all checkbox are unchecked (have lost data) text fields are clear. How Can i saved these data in original state when go back from camera activity My code are as follow
Main activity
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
irisContext = this;
mHandler = new Handler();
getGUIFromXMLDoc();
.
.
.
. so on
all other button click function called in getGUIFromXMLDoc()
function etc
sorry for my poor English. I hope you can understand my question
i have alread开发者_Python百科y look at some similar question on this blog but not any relevant answer or not clearly explained
please help me as soon as possible
start your Camera Activity like this way
Intent mainIntent = new Intent(this, MAINActivity.class);
startActivityForResult(mainIntent);
it will start the camera activity as child don't start new activity from camera when you complete camera activity finish this way
setResult(RESULT_OK);
finish();
of if cancel from that activity then do like this
setResult(RESULT_CANCEL);
finish();
now it will finish the camera activity and go back to the main activity
You can save activity state in the callback method onSaveInstanceState() in your MainActivity. When you'll back to this activity next time, you may retrieve data from Bundle in onCreate() method.
Another way is to start MyCamera activity with startActivityForResult(), and after MyCamera activity is done, set result value and finish it.
精彩评论