I’m testing an object that’s supposed to start a new activity when the open(url) method is called on it :
public void open(String url) {
Intent i = new Intent(getContext(), Browser.class);
Log.d(TAG, "open:" + url);
i.putExtra("URL", url);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(i);
}
I’d like to get the instance of the activity, and check some parameters based on the URL.
I found this snipped :
ActivityManager am = (ActivityManager) mActivity
.getSystemService("activity");
List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
ComponentName componentInfo = taskInfo.get(0).topActivity;
but it only returns the name of the class, and I’d like to assert stuff on the instance of the activity.
Has anybody an idea on how to do this?
Thanks 🙂
Julien
Ok, I’ve found a solution : the ActivityMonitor Class :