Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old June 16th, 2010, 07:21 PM   #1 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Jun 2010
Posts: 21
 
Device(s):
Carrier: Not Provided

Thanks: 5
Thanked 0 Times in 0 Posts
Question startActivityForResult ??????

I open a new activity by calling startActivityForResult.
Inside my SecondActivity class i have an exit button, when the user clicks it i need to close the SecondActivity.
What method should i call to close SecondActivity?
I tried calling finish() and finishActivity() on my exitButtonClicked, but it didn't do anything.
Code:
public class FirstActivity extends Activity {
     public void onCreate(Bundle savedInstanceState) {
     .......
     .......
     Intent i = new Intent(this , SecondActivity.class);
     this.startActivityForResult(i, 1);
     }
}
Code:
public class SecondActivity extends Activity {
     private void exitButtonClicked()
     {
          //I need to call a method to close this activity
     }
}

Advertisements
aryaxt is offline  
Last edited by aryaxt; June 16th, 2010 at 08:55 PM.
Reply With Quote
sponsored links
Old June 16th, 2010, 10:58 PM   #2 (permalink)
Member
 
Join Date: Feb 2010
Location: Seattle, WA, USA
Posts: 111
 
Device(s): Nexus One, Motorola Cliq, G1
Carrier: Not Provided

Thanks: 1
Thanked 19 Times in 17 Posts
Default

You want to do something like

setResult(RESULT_OK, result);
finish();

or

setResult(RESULT_CANCELED, null);
finish();
IanGClifton is offline  
Reply With Quote
The Following User Says Thank You to IanGClifton For This Useful Post:
aryaxt (June 17th, 2010)
Old June 17th, 2010, 09:01 PM   #3 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Jun 2010
Posts: 21
 
Device(s):
Carrier: Not Provided

Thanks: 5
Thanked 0 Times in 0 Posts
Default

thanks setting the result solved the problem
aryaxt is offline  
Reply With Quote
Reply
Tags
activity, close activity, startactivityforresult


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:03 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.