gpt4 book ai didi

android:打开wifi时无法发送彩信

转载 作者:搜寻专家 更新时间:2023-11-01 09:12:57 27 4
gpt4 key购买 nike

我想在后台发送彩信到我的项目中,我这样写我的代码: How to send image via MMS in Android?

但是如果 wifi 打开,我无法发送彩信。如果 wifi 关闭,我可以发送我的彩信成功。

当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 发送我的彩信。我试过这样

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

MMS sending connectivity issues when wifi is active (Android)

但是问题依旧,请帮帮我...

最佳答案

我已经解决了这个问题。在打开 wifi 时发送彩信之前,首先你应该调用这个方法:

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

当连接处于 Activity 状态时,您需要调用此方法:

ConnectivityManager.requestRouteToHost(ConnectivityManager.TYPE_MOBILE_MMS,PROXY);

如果返回true,说明发送彩信成功。

关于android:打开wifi时无法发送彩信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6924718/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com