Asqan
Asqan

Reputation: 4489

How to set Intent and Configuration before starting activity in Robolectric

My Activity -that i want to test- has to have extras before starting which had to be located in Intent. How can i add them before lunching the activity in testing?

And the same function is also needed to set the "Locale" in "Configuration" in Activity.

I think that we have to use shadowActivity but i could not find any example for that.

Please help & Thank you!

Upvotes: 0

Views: 1318

Answers (1)

Bateramos
Bateramos

Reputation: 156

About the extras, I don't see any problem. Just create a new Intent, put all the extras and set in our activity.

Intent intent = new Intent();
intent.putExtra(..,..);
activity.setIntent(intent);
activity.onCreate(null);

Upvotes: 1

Related Questions