My requirement is One activity is calling another activity.When I click the radio button from list of sales route in the parent activity , dialog(that is called child) will come.That contain form. After finish tiny form work , it go to previous place(need to continue rest of work).
I have done like this:
Androidmanifest.xml
<activity android:theme="@android:style/Theme.Light.Panel" android:name=".SalesRouteDevitionActivity"
android:label="Sales Route Diviation">
</activity>
Then My list of sales route java part is:
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
keyword = o.toString();
positions = position;
if(position != 0 ){
Bundle bundle = new Bundle();
Intent showContent = new Intent(v.getContext(),SalesRouteDevitionActivity.class);
int postion = position;
String aString = Integer.toString(postion);
bundle.putString("positon", aString);
showContent.putExtras(bundle);
startActivityForResult(showContent, 2);
}else{
Intent intent = new Intent(SalesRouteActivity.this, ListRetailerActivity.class);
Bundle bundle = new Bundle();
bundle.putString("RouteName", keyword);
intent.putExtras(bundle);
View view = SalesActivityGroup.group.getLocalActivityManager().startActivity("", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
SalesActivityGroup.group.replaceView(view);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if( resultCode==Activity.RESULT_OK){
Toast.makeText(this, "Reason has been successfully.", Toast.LENGTH_LONG).show();
if(resultCode==RESULT_OK)
Toast.makeText(this, "Reason has been successfully.", Toast.LENGTH_LONG).show();
else
Toast.makeText(this, "Fail", Toast.LENGTH_LONG).show();
}
// super.onActivityResult(requestCode, resultCode, data);
}
And my child activity is :
public class SalesRouteDevitionActivity extends Activity {
private String array_spinner[];
String param1 = "";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.route_diviation_popup);
array_spinner=new String[2];
array_spinner[0]="Rain";
array_spinner[1]="Floods";
Spinner s = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, array_spinner);
s.setAdapter(adapter);
Button button = (Button) findViewById(R.id.submit);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent= new Intent(getApplicationContext(),SalesRouteActivity.class);
Log.i("*********" ," --- " +getParent());
if (getParent() == null) {
setResult(RESULT_OK, intent);
} else {
getParent().setResult(RESULT_OK, intent);
}
finish();
}
});
}
My problem is after finish popup activity, It didn't go to onActivityResult()
method
I have a doubt, if the theme is @android:style/Theme.Dialog
then can we use onActivityResult()
;
Please help me ...
I am spending more than one day.... may be small issue ....
Thanks in advance....