专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > BlackBerry

访问网络数据有关问题,http get json (中移动,CTM网络)

发布时间:2010-05-30 19:39:10 文章来源:www.iduyao.cn 采编人员:星星草
访问网络数据问题,http get json (中移动,CTM网络)
开发了一个小程序,访问http get json .模拟器测试没问题。真机9780(WIFI,中国移动SIM卡)测试没问题。

。但是换了澳门的CTM手机卡后,只有手机自带的浏览器可以上网,我的程序不能访问网络,而且手机QQ,新浪都上不了。。。求解。
安装在别人的手机上9900(网络澳门CTM),程序访问不了网络。

private ConnectionFactory factory;
private ConnectionDescriptor conDescriptor;
private ReturnMessage retuMsg;
public HttpConnect() {
// TODO Auto-generated constructor stub
factory=new ConnectionFactory();
}

//get
public ReturnMessage parseGetJsonByUrl(String url){
retuMsg=new ReturnMessage();
InputStream is=null;
HttpConnection conn=null;
OutputStream os=null;
String temp="";
try {

conDescriptor=factory.getConnection(url);
System.out.println("url="+url);
if(conDescriptor!=null){
conn=(HttpConnection)conDescriptor.getConnection();
conn.setRequestMethod(HttpConnection.GET);
conn.setRequestProperty("User-Agent", "BlackBerry/5.0.0");
conn.setRequestProperty("Content-Type","application/json");

retuMsg.setHttpcode(conn.getResponseCode());
is=conn.openInputStream();
int length=(int)conn.getLength();
StringBuffer sb=new StringBuffer();
if(length>0){
byte servletData[]=new byte[length];
int i=-1;
while((i=is.read(servletData))!=-1){
sb.append(new String(servletData,0,i,"utf-8"));
}
temp=sb.toString();
System.out.println("chao"+temp);
}else{
System.out.println("Elex get length <0");
}
retuMsg.setJson(temp);

}
}catch (Exception e) {
// TODO: handle exception
System.out.println("http get json error:"+e.toString());
}
finally{
try {
if(is!=null){
is.close();
}
if(os!=null){
os.close();
}
if(conn!=null){
conn.close();
}
} catch (Exception e2) {
// TODO: handle exception
System.out.println(e2.toString());
}
}

return retuMsg;
}
按理说上面的代码是可以自动选择网关的啊????

请问大家有没有遇到这样的问题?
1.是手机设置的问题?
2.还是代码的问题?

------解决方案--------------------
如果你是为客户开发澳门地区使用的黑莓应用,必须使用CTM网络,那么
1)开通CTM的黑莓BIS服务,走BIS通道上网
2)尝试走一下WAP 2.0通道,一般运营商都支持的
3)打电话问CTM客服,问手机上网设置,比如apn,或者是wap gateway的IP地址,端口

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: