我的brodcastreceiver成功收到彩信,但我无法从URL GET请求下载数据。 当我收到请求时: IOException超时。
public class MMSReceiver extends BroadcastReceiver {
Context context;
ConnectivityManager manager;
public void onReceive(final Context context, Intent intent) {
this.context = context;
Bundle bundle = intent.getExtras();
manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
byte[] buffer = bundle.getByteArray("data");
GenericPdu genericPdu = new PduParser(buffer).parse();
ContentValues vl = getParams(genericPdu);
final String contentLocation = "http://mmscr:8002/0420000037936141022152222001";
new Thread(new Runnable() {
@Override
public void run() {
try {
ensureRouteToHost(context, contentLocation , "10.10.10.10");
// THIS HTTP GET REQUEST \/\/\/\/\/\/
byte[] rawPdu = HttpUtils.httpConnection(context, SendingProgressTokenManager.NO_TOKEN,contentLocation , null, HttpUtils.HTTP_GET_METHOD, true, "10.10.10.10", 8080);
Log.i("mLogs", "DATA :" + rawPdu.length);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
答案 0 :(得分:0)
大多数运营商MMS中继服务器驻留在公共互联网无法访问的专用网络中。您需要使用单独的APN,有时使用HTTP代理来访问包含MMS消息正文的URL。确保在调用ensureRouteToHost()之前,您已连接到正确的APN,并且如果您的运营商需要HTTP代理,则使用HTTP代理。