android 自定义发送彩信的问题
程序cmwap连不上网络,发送不成功,怎么会这样,代码是网上找的,通过logcat看连接超时,大家帮我看看,是哪里出问题了private static final String TAG = "MMSSender";
public static String mmscUrl = "http://mmsc.monternet.com";
public static String mmsProxy = "10.0.0.172";
public static int mmsProt = 80;
private static String HDR_VALUE_ACCEPT_LANGUAGE = "";
private static final String HDR_KEY_ACCEPT = "Accept";
private static final String HDR_KEY_ACCEPT_LANGUAGE = "Accept-Language";
private static final String HDR_VALUE_ACCEPT = "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic";
public static byte[] sendMMS(Context context, byte[] pdu)
throws IOException {
System.out.println("进入sendMMS方法");
// HDR_VALUE_ACCEPT_LANGUAGE = getHttpAcceptLanguage();
HDR_VALUE_ACCEPT_LANGUAGE = HTTP.UTF_8;
if (mmscUrl == null) {
throw new IllegalArgumentException("URL must not be null.");
}
HttpClient client = null;
try{
HttpHost httpHost = new HttpHost(mmsProxy, mmsProt);
HttpParams httpParams = new BasicHttpParams();
httpParams.setParameter(ConnRouteParams.DEFAULT_PROXY, httpHost);
HttpConnectionParams.setConnectionTimeout(httpParams, 10000);
client = new DefaultHttpClient(httpParams);
HttpPost post = new HttpPost(mmscUrl);
// mms PUD START
ByteArrayEntity entity = new ByteArrayEntity(pdu);
entity.setContentType("application/vnd.wap.mms-message");
post.setEntity(entity);
post.addHeader(HDR_KEY_ACCEPT, HDR_VALUE_ACCEPT);
post.addHeader(HDR_KEY_ACCEPT_LANGUAGE, HDR_VALUE_ACCEPT_LANGUAGE);
post.addHeader("user-agent", "Mozilla/5.0(Linux;U;Android 2.1-update1;zh-cn;ZTE-C_N600/ZTE-C_N600V1.0.0B02;240*320;CTC/2.0)AppleWebkit/530.17(KHTML,like Gecko) Version/4.0 Mobile Safari/530.17");
// mms PUD END
HttpParams params = client.getParams();
HttpProtocolParams.setContentCharset(params, "UTF-8");
System.out.println("准备执行发送");
Log.v("MMSSender", "准备执行发送");
HttpResponse response = client.execute(post); Android 网络 --------------------编程问答-------------------- 只能运行到最后一行 HttpResponse response = client.execute(post);
然后就报错连接超时 connect 10.0.0.172:80 time out
崩溃啊 --------------------编程问答-------------------- 呵呵,解决了,是pdu格式错了,呵呵,可以发送了,来个人吧,把分给了 --------------------编程问答-------------------- 请问你是如何解决的,我现在遇到与你同样的问题。一直报错连接超时 connect 10.0.0.172:80 time out现在不知道怎么解决。请问pdu格式数据如何封装? --------------------编程问答-------------------- 刚才忘给你联系方式了,我的QQ:742264104,邮箱:zhanqi889@163.com --------------------编程问答-------------------- 楼主,你是如何解决的啊? --------------------编程问答-------------------- 能给个代码吗,qq:245227506 Email 245227506@qq.com
补充:移动开发 , Android