开发者

android: can not send out mms when wifi is on

I want to send mms in my project in background, I write my code like this: How to send image via MMS in Android?

But if the wifi is on, i can not send out my mms. if the wifi is off, i can send out my mms sucessful.

when the wifi is on, I got an error like this:

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.execut开发者_如何学Ce(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)

I think it used wifi to send out my mms.i have tried like this

 ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
connMgr.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
                "enableMMS");

MMS sending connectivity issues when wifi is active (Android)

But the issue is still on, Please give me some help...


I have fixed the issue. Before send the mms when wifi is on, first you should call this method:

ConnectivityManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,"enableMMS");

When the connection is active, you need to call this method:

ConnectivityManager.requestRouteToHost(ConnectivityManager.TYPE_MOBILE_MMS,PROXY);

If it returns true ,you can send out the mms sucessful.


I had a similar issue, it would seem that it may be related to the use of AndroidHttpClient (in HttpUtils). Replacing it with DefaultHttpClient did the trick for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜