我正在努力使VPN服务在Android上运行.
为此,我想我必须使用由Android SDK提供的VpnService类中提供的Builder类.现在,当我尝试这样做时,方法
builder.establish()
返回null.这是我写的完整方法;
// If theInterface still exists from last time, reuse it, it has the same parameters.
if (theInterface != null) {
    return;
}
// configure the VPN settings.
Builder builder = new Builder();
builder.setMtu(1500);
builder.addAddress("10.0.2.0", 32);
builder.addRoute("0.0.0.0", 0);
try {
    theInterface.close();
} catch (Exception e) {
    // Ignore
}
theInterface = builder.establish();
Log.i(TAG + "IMPORTANT", builder.toString());
代码崩溃在: 
Log.i(TAG + "IMPORTANT", builder.toString());
调试时,调试器在整个程序执行过程中显示"theInterface = null".
编辑:
我看过位于android.net.VpnService的Builder类
在这个类中,似乎有一个隐藏的类(IConnectivityManager),也许我的问题与此有关... 
这是一块我正在谈论的代码.
/**
 * Use IConnectivityManager since those methods are hidden and not
 * available in ConnectivityManager.
 */
private static IConnectivityManager getService() {
    return IConnectivityManager.Stub.asInterface(
            ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
}
作为VpnService.Builder.establish 文档:
__CODE__
:需要呼叫VpnService.prepare http://developer.android.com/reference/android/net/VpnService.html#prepare(android.content.Context) 第一