1
votes
private Button.OnClickListener goFirstPage = new Button.OnClickListener() {

public void onClick(View v) { try {

Intent i = new Intent(v.getContext(), quizMath.class); startActivityForResult(i, 0);

} catch (Exception e) { e.printStackTrace(); // TODO: handle exception }

} }; hi, this is my code, but the problem is that i want to call a function from class quizmath.So is it possible or not?. can we pass integer or string from startActivityForResult?

1

1 Answers

1
votes

Yes it's possible. You'll find documentation for Intent here http://developer.android.com/reference/android/content/Intent.html

Before you start the activity you can use the putExtra function on your intent.

i.putExtra( "yourapp.function_to_call", "subtract" );

This is going to be passed to your activity and you can get out the information with the Intent.getStringExtra function. In your activity you can then do something like this.

Intent i = this.getIntent();
String fname = i.getStringExtra( "yourapp.function_to_call" );
if( fname.equals("add") )
    // ...