Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.lang.reflect.Method;
import android.content.Context;

public class Main {
    public static int untetherIface(Context context, String iface) {
        int returnCode = -1;
        Object connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE);
        Method untether = null;
        try {
            untether = connectivityManager.getClass().getMethod("untether", new Class[] { String.class });
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            returnCode = (Integer) untether.invoke(connectivityManager, new Object[] { iface });

        } catch (Exception e) {
            e.printStackTrace();
        }
        return returnCode;
    }
}