我想在后台发送我的项目中的mms,我写这样的代码: How to send image via MMS in Android?
但如果wifi打开,我就无法发送我的mms。 如果wifi关闭,我可以发送我的mms成功。
当wifi打开时,我收到如下错误:
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): org.apache.http.conn.ConnectTimeoutException: Connect to /10.0.0.172:80 timed out
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:359)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at src.mmstest.AndroidHttpClient.execute(AndroidHttpClient.java:280)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at src.mmstest.HttpConnectInterface.sendMMS(HttpConnectInterface.java:119)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at src.mmstest.MmsTest$MmsReceiver$1.run(MmsTest.java:57)
08-04 11:27:06.460: ERROR/HttpConnectInterface(26830): at java.lang.Thread.run(Thread.java:1019)
我认为它使用wifi发送我的mms.i尝试了这样的
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
connMgr.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
"enableMMS");
MMS sending connectivity issues when wifi is active (Android)
但问题仍然存在,请给我一些帮助......
答案 0 :(得分:3)
我已经解决了这个问题。 在打开wifi之前发送mms之前,首先应该调用此方法:
ConnectivityManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,"enableMMS");
当连接处于活动状态时,您需要调用此方法:
ConnectivityManager.requestRouteToHost(ConnectivityManager.TYPE_MOBILE_MMS,PROXY);
如果它返回true,你可以发出成功的mms。
答案 1 :(得分:0)
我有一个类似的问题,似乎它可能与使用AndroidHttpClient(在HttpUtils中)有关。用DefaultHttpClient替换它对我来说很有用。