Though there are several questions regarding this topic, I could not find a right answer to this.
I have a main activity (This is one activity in a tabview) from where I am calling the login activity.
Button chdbtn=(Button)findViewById(R.id.Add); chdbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(main.this, Login.class); startActivityForResult(myIntent, 1001); } }); protected void onActivityResult(int requestCode, int resultCode, Intent data){ if(requestCode == 1001) { if(resultCode == RESULT_OK) { Log.i("Info","Inside"); } } }
And in my login class, When I click on a button, I am doing this
Button chdbtn=(Button)findViewById(R.id.Addchild); chdbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent Ireturn = new Intent(); setResult(RESULT_OK,Ireturn); finish(); } });
But when I click on the button in login activity, the control is not coming to the main activities onActivityResult method. Can anyone guide me what is the issue.
VIJAYapp.sample.ChildEntry1$1/onClick:23
INFO/ActivityManager(59): Starting activity: Intent { cmp=app.sample/.ChildLogin }
WARN/ActivityManager(59): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { cmp=app.sample/.ChildLogin }
DEBUG/PhoneWindow(999): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@43e4b620 has no id.
INFO/ActivityManager(59): Displayed activity app.sample/.ChildLogin: 460 ms (total 460 ms)
INFO/VIJAY(999): VIJAYapp.sample.ChildLogin$1/onClick:24
Above is the log that I am getting when clicking on the buttons. I can see that there is some problem with the Activity..any answers?