snehal
snehal

Reputation: 181

how to get current visible android.support.v4.app.Fragment in robotium

I am using robotium 3.6 and I want to get the current visible fragment of android.support.v4.app.FragmentActivity. How to do this?

Upvotes: 1

Views: 909

Answers (1)

Paul Harris
Paul Harris

Reputation: 5819

Assuming you are actually using the FragmentActivity, then solo.getCurrentActivity() should return the activity you want but it will be casted to an activity, you will need to cast it to an android.support.v4.app.FragmentActivity in the normal java way:

android.support.v4.app.FragmentActivity fragmentActivity = (android.support.v4.app.FragmentActivity) solo.getCurrentActivity();

This may not work if you have this inside a tabhost or such though.

Upvotes: 1

Related Questions