Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.89 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to getValue the data on setActivityForresult
  2. public void onGeneralKnowledgeClick(View v) {
  3.     createIntent("GENERAL_KNOWLEDGE", 1);
  4.  
  5. }
  6.     ........
  7.     ........
  8.     ........
  9. public void onCelebritiesClick(View v) {
  10.     createIntent("CELEBRITIES", 6);
  11. }
  12.  
  13. private void createIntent(String category, int result) {
  14.     Bundle bundle = new Bundle();
  15.     bundle.putInt(category, result);
  16.     Intent intent = new Intent(this.getApplicationContext(),
  17.             QuestionActivity.class);
  18.     intent.putExtras(bundle);
  19.     startActivityForResult(intent, 0);
  20. }
  21.        
  22. private int getCategory() {
  23.    Bundle bundle = this.getIntent().getExtras();
  24.       int categ = bundle.getInt("GENERAL_KNOWLEDGE");
  25.    return categ;
  26.  
  27. }
  28.        
  29. bundle.putInt("CATEGORY", result); //where result == the categoryId and "CATEGORY" is always "CATEGORY"
  30.        
  31. int categ = bundle.getInt("CATEGORY") //you'll get the int value that you fed before