Reputation: 253
I have a MainActivity, one NonActivity class and SearchActivity. NonActivity class calls startActivityForResult, but onActivityResult in nonActivity class is never called.
But I figured it out, that is called in MainActivity, when I implemented it for testing purposes. Could you please tell me if it is possible, that onActivityResult will be called from nonActivity class?
This is the code I am calling from NonActivity class.
Intent intent = new Intent(activity, SearchActivity.class);
//start SearchActivity through intent and expect for result. The result is based on result code, which is REQUEST_DISCOVERY
activity.startActivityForResult(intent, REQUEST_DISCOVERY);
}
Thanks for your answer, if you need more code, I can put add.
Upvotes: 0
Views: 548
Reputation: 40193
onActivityResult()
won't be called on a NonActivity
class, because actually it wasn't the one that started the new Activity
, your calling startActivityForResult()
on your MainActivity
object and MainActivity
is where the onActivityResult()
will be called. To call it back to the NonActivity
just create a method inside the NonActivity
and call it from the MainActivity's
onActivityResult()
, passing the arguments that you need.
Upvotes: 2