code_junkie

Android: Capturing the return of an activity

Nov 13th, 2011
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. Intent i = new Intent(this,CameraActivity.class);
  2. startActivity(i);
  3.  
  4. Intent i = new Intent(this,CameraActivity.class);
  5. startActivityForResult(i, STATIC_INTEGER_VALUE);
  6.  
  7. resultIntent = new Intent(null);
  8. resultIntent.putExtra(PUBLIC_STATIC_STRING_IDENTIFIER, tabIndexValue);
  9. setResult(Activity.RESULT_OK, resultIntent);
  10. finish();
  11.  
  12. @Override
  13. public void onActivityResult(int requestCode, int resultCode, Intent data) {
  14. super.onActivityResult(requestCode, resultCode, data);
  15. switch(requestCode) {
  16. case (STATIC_INTEGER_VALUE) : {
  17. if (resultCode == Activity.RESULT_OK) {
  18. int tabIndex = data.getIntExtra(PUBLIC_STATIC_STRING_IDENTIFIER);
  19. // TODO Switch tabs using the index.
  20. }
  21. break;
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment