2014-10-27 57 views
1

我的brodcastreceiver成功接收MMS,但無法從URL GET請求下載數據。 當我收到請求時:IOException超時。無法從URL GET請求中下載數據mms

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(); 

} 
+1

[MMS Android Receiver]可能的重複(http://stackoverflow.com/questions/26551170/mms-android-receiver) – LoungeKatt 2017-04-20 17:51:58

+0

@Chekin你有沒有找到一個工作解決方案? – not2qubit 2017-05-23 10:12:44

回答

0

大多數運營商MMS中繼服務器駐留在私有網絡這是從公共互聯網訪問。您需要使用單獨的APN,有時需要使用HTTP代理來訪問包含彩信主體的URL。確保在調用ensureRouteToHost()之前,您已連接到正確的APN,並且如果您的操作員需要使用HTTP代理。

+0

一個代碼示例本來就很棒... – not2qubit 2017-05-23 10:13:07