Reputation: 2821
hi i have two activities , first acivity has three icons one is invisible...when i click on the first actitvity it goes to the second activity using intent..my second activity is a login screen ,when the login is success i should come back to first activity and make an icon visible in the first acitivty..how can i go back to first activity from second activity and make the icon visible in first one..below is my login screen code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fyelogin);
etPassword = (EditText)findViewById(R.id.password);
btnLogin = (Button)findViewById(R.id.login_button);
btnCancel = (Button)findViewById(R.id.cancel_button);
lblResult = (TextView)findViewById(R.id.result);
final ImageView details = (ImageView)findViewById(R.id.red);
btnLogin.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String password = etPassword.getText().toString();
if(password.equals("guest")){
lblResult.setText("password successful.");
// details.setVisibility(View.VISIBLE);
} else {
lblResult.setText("password doesn't match.");
}
finish();}});
any suggestions/ help is appreciated...
Upvotes: 1
Views: 86
Reputation: 15973
Use startActivityforResult
to open the login activity..then in the onActivityResult(int, int, Intent)
in your first activity show the icon..
Example:
public class MyActivity extends Activity {
...
static final int PICK_CONTACT_REQUEST = 0;
protected boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
// When the user center presses, let them pick a contact.
startActivityForResult(
new Intent(Intent.ACTION_PICK,
new Uri("content://contacts")),
PICK_CONTACT_REQUEST);
return true;
}
return false;
}
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == PICK_CONTACT_REQUEST) {
if (resultCode == RESULT_OK) {
// A contact was picked. Here we will just display it
// to the user.
startActivity(new Intent(Intent.ACTION_VIEW, data));
}
}
}
}
check http://developer.android.com/reference/android/app/Activity.html
Upvotes: 2