彩信发送的连接问题时,WiFi是积极的(Android版) [英] MMS sending connectivity issues when wifi is active (Android)

查看:299
本文介绍了彩信发送的连接问题时,WiFi是积极的(Android版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Android应用程序,将在内部发送彩信,而不使用原生的消息应用程序。我一直在使用code从本机应用程序,我发现在 HTTP://android.git。 kernel.org/~~V 为指导,并已成功地创造出一个工作原型。
然而,试图让HTTP_POST当手机连接到无线时,我有一个轻微的问题。

I'm working on an Android application that will send MMS internally without using the native messaging app. I've been using the code from the native app that I found at http://android.git.kernel.org/ as a guide and have managed to create a working prototype. However, I'm having a slight issue when trying to make the HTTP_Post when the phone is connected to Wifi.

在下面的code片段我请求MMS网络功能,并等待android.net.conn.CONNECTIVITY_CHANGE意图表明连接处于激活状态。然后我要求的NetworkInfo为TYPE_MOBILE并检查它是否已连接。这是我打的问题。如果WiFi连接,当我打电话info.isConnected()返回false,不能做彩信HttpPost因为这个职位必须通过3G / GPRS连接进行。

In the code snippet below I request the MMS network feature and wait for the android.net.conn.CONNECTIVITY_CHANGE intent indicating the connection is active. I then request the NetworkInfo for TYPE_MOBILE and check that it is connected. This is where I hit the issue. If the wifi is connected, when I call info.isConnected() it returns false and the MMS HttpPost cannot be made as this post must be made through the 3G/GPRS connection.

ConnectivityManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, "enableMMS");
//wait for android.net.conn.CONNECTIVITY_CHANGE intent
NetworkInfo info = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (!info.isConnected())
     return;

我可以让它开始工作的唯一方法是通过断开此时info.isConnected()返回true,我可以继续做HttpPost成功的无线网络。但我不认为这是执行此功能的本机应用程序似乎并没有做到这一点的正确方法。
从我所看到的,本地消息应用程序的TransactionService.java使用内部,德precated类,NetworkConnectivityListener,以管理连接,但我看不出在其code任何修改WiFi连接。

The only way I can get it to work is by disconnecting the wifi at which point info.isConnected() returns true and I can go on to make the HttpPost successfully. But I don't think this is the correct way of performing this function as the native app doesn't seem to do this. From what I can see, the native messaging app's TransactionService.java uses an internal, deprecated class, NetworkConnectivityListener, to manage the connection but I can't see anything in its code that modifies the Wifi connection.

有没有人也有类似的问题,这个还是知道的来解决它的正确方法?
我的ConnectivityManager文档中发现有一个连接类型TYPE_MOBILE_MMS,但我没有试过这个,因为它是唯一通过运行2.2及以上的设备支持,我希望能够支持运行1.6的设备。

Has anyone had a similar issue to this or know of the correct way to work around it? I noticed in the ConnectivityManager documentation there's a connection type TYPE_MOBILE_MMS but I haven't tried this as it's only supported by devices running 2.2 and above and I want to be able to support devices running 1.6.

任何帮助将是最AP preciated。

Any help would be most appreciated.

推荐答案

我发现了问题,不得不使用上运行2.0及以上的设备的android.net.ConnectivityManager.TYPE_MOBILE连接类型做。有了这些,你需要使用TYPE_MOBILE_MMS和1.6的设备只使用TYPE_MOBILE。
有没有需要断开无线网络。

I found out the issue had to do with using the android.net.ConnectivityManager.TYPE_MOBILE connection type on devices running 2.0 and above. With these you need to use TYPE_MOBILE_MMS and for 1.6 devices just use TYPE_MOBILE. There is no need to disconnect the wifi.

这篇关于彩信发送的连接问题时,WiFi是积极的(Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆