- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试让 VPN 服务在 Android 上运行。
为此,我想我必须使用 VpnService 类中提供的 Builder 类,它由 android SDK 提供。现在,当我尝试这样做时,方法
builder.establish()
返回空值。这是我写的完整方法;
// 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 documents :
Returns ParcelFileDescriptor of the VPN interface, or null if the application is not prepared.
需要调用 VpnService.prepare: http://developer.android.com/reference/android/net/VpnService.html#prepare(android.content.Context)第一
关于java - Android VPN Service Builder.establish() 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29221665/
我最近开始使用 MSpec,将类分为 Establish、Because 和 It。 虽然我知道如何使用它们,但我不确定是什么让它们起作用。 我知道他们是代表 Because of = () => {
我的理解是每个 Establish 应该只执行一次,但下面的代码显示它执行了多次。我们嵌套类以提供一些分组,同时将 Subject 的单元测试保留在一个文件中。这似乎是一个错误。 我们正在使用 mac
我一直在谷歌上广泛搜索,试图解决这个问题,但似乎找不到解决方案。我正在尝试在我的 Chrome 扩展程序中完成设置监听器和发送器的简单任务。 我的 list { "manifest_version
这个错误是我从 lastError.js 文件中得到的,我没有在我的 html 页面中调用它。 var errorMessage = name + ': ' + message; if (sta
我的一个 AMQ 生产者有问题,我有网络问题,因此它无法向 Q 发送消息。然而,服务器打开与 Q 机器的连接并保持它们完好无损。连接数增加,Q 机器窒息,无法为其其余生产者和消费者提供服务。 这是我在
尝试从弹出窗口向我的 contentscript 发送消息时出现此错误。我想要做的是从我的 content.js 获取当前选项卡的文档并将其发送到弹出窗口。我该如何解决这个错误? { "manif
我有一个 Java 网络爬虫。我注意到,对于我抓取的少量服务器,我留下了大量已建立的套接字: joel@bohr:~/tmp/test$ lsof -p 6760 | grep TCP java
我正在使用 Unitt 库 ( http://code.google.com/p/unitt/wiki/UnittWebSocketClient ) 尝试在我的 iOS (iPhone) 应用程序中通
我正在使用 EWS Java API 连接 Exchange 服务器并检索有关邮件、日历约会和任务的信息。 除一个帐户外,它适用于许多用户。我收到以下错误: microsoft.exchange.we
我想使用 C/C++ 获取到我的服务器的 SYN 和 ESTABLISHED 连接数。但我不想调用 popen 来运行 netstat 或任何其他 Linux 命令。我设法扫描了/proc/net/i
我正在测试应用程序尝试访问未知 URL 时的行为。引发 ConnectionError 需要 5 秒。我怎样才能修改为在 100 毫秒时失败? 我尝试使用 requests.get(url, time
当我尝试为我的 VpnService 创建隧道接口(interface)时,出现以下错误: Attempt to invoke virtual method 'java.lang.String and
如果有一个网络服务器在端口 80 上运行,并且有人使用随机分配的端口 x 从客户端连接,那么服务器知道要回复哪个端口。但是,从那时起,与服务器的通信是否从那时起继续在端口 80 上进行(将文件描述符分
我做了一个实验: 一个监听8804端口的服务器接受一个客户端的连接,然后无休止地向客户端发送数据。我关闭了网络。 当我运行 netstat -anotp | grep 8804 ,显示服务器和客户端的
我正在尝试使用 JSch通过 ssh 连接到我的计算机,然后运行命令。 但是,当我运行代码时,我从未连接到计算机。和以下错误: I/System.out: com.jcraft.jsch.JSchEx
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
尝试为我们的Intranet的Web服务站点设置一个自签名证书。证书本身表明它是“ok”,但是当尝试从Web服务调用方法时,它会引发错误,并且在添加Web引用时也会给出警告。 这是确保我提供准确信息的
我正在使用 JavaScript 和 Union platform我将如何诊断这个问题?非常感谢。 最佳答案 如果你去http://jsbin.com/ekusep/6/edit并查看 JavaScr
我正在尝试设置一个保存点,并在遇到问题时回滚到该点。但我收到以下消息: SQL execution error, ORA-01086: savepoint 'LASTSAVE' never estab
我只有一个托管对象上下文。 不过我已经修改了托管对象存储。 我想将某些字段添加到每个托管对象中。将它们一一添加到系统中的每个对象会花费太多时间,因此我决定以编程方式将它们添加到托管对象模型中。在应用程
我是一名优秀的程序员,十分优秀!