
Untitled
By: a guest on
May 11th, 2012 | syntax:
None | size: 0.89 KB | hits: 17 | expires: Never
How to getValue the data on setActivityForresult
public void onGeneralKnowledgeClick(View v) {
createIntent("GENERAL_KNOWLEDGE", 1);
}
........
........
........
public void onCelebritiesClick(View v) {
createIntent("CELEBRITIES", 6);
}
private void createIntent(String category, int result) {
Bundle bundle = new Bundle();
bundle.putInt(category, result);
Intent intent = new Intent(this.getApplicationContext(),
QuestionActivity.class);
intent.putExtras(bundle);
startActivityForResult(intent, 0);
}
private int getCategory() {
Bundle bundle = this.getIntent().getExtras();
int categ = bundle.getInt("GENERAL_KNOWLEDGE");
return categ;
}
bundle.putInt("CATEGORY", result); //where result == the categoryId and "CATEGORY" is always "CATEGORY"
int categ = bundle.getInt("CATEGORY") //you'll get the int value that you fed before