Code example for Instrumentation

Methods: getTargetContext

0
	private final ConnectivityManager connectivityManager;
	private final Object sync = new Object();
 
	public Contexter(Instrumentation instr) {
		instrumentation = instr;
		connectivityManager = (ConnectivityManager) instrumentation.getTargetContext().getSystemService(Context.CONNECTIVITY_SERVICE);
		Log.d(TAG, "Thread " + getThreadId() + ": initialised contexter");
	} 
 
	public void establishContext(de.viadee.context.Context context) throws Exception {
		setNetworkStatus(context.getInternetConnectionStatus());
	} 
 
	public void setNetworkStatus(ConnectionStatus status) throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException,
			IllegalAccessException, InvocationTargetException, NoSuchFieldException, InterruptedException { 
		Log.d(TAG, "Mobile Internet is " + getMobileNetworkStatus());
		Log.d(TAG, "Setting Mobile internet to " + status);
		setMobileDataConnection(status);
	} 
 
	private void setMobileDataConnection(final ConnectionStatus desiredStatus) throws ClassNotFoundException, SecurityException, NoSuchMethodException,