当前位置: 编程技术>移动开发
本页文章导读:
▪获取ChoiceGroup多选状态上的值 获取ChoiceGroup多选状态下的值
http://javaeye.5d6d.com/thread-233-1-1.html
怎么样获取ChoiceGroup多选状态下的值呢?
连我这个做了几个小项目的程序员,今天都不知道怎么办了。
看了api文档不是很清.........
▪ 腾挪资费提示过滤 移动资费提示过滤
最近移动对网关进行改造,会弹出一个资费提示的wap页面,干扰了众多手机应用,手机网络游戏的正常运行,仅提供一个移动资费提示过滤的工具类代码,以抛砖引玉
pa.........
▪ think in java 汉语言文档 think in java 中文文档
think in java 中文文档
......
[1]获取ChoiceGroup多选状态上的值
来源: 互联网 发布时间: 2014-02-18
获取ChoiceGroup多选状态下的值
http://javaeye.5d6d.com/thread-233-1-1.html
怎么样获取ChoiceGroup多选状态下的值呢?
连我这个做了几个小项目的程序员,今天都不知道怎么办了。
看了api文档不是很清晰,还是动手实践下吧。
看代码就知道了
boolean[] flags = new boolean[this.images.size()];
for(int i=0; i < flags.length; i++){
if(flags)
this.images.getString(i); //这里得的选中的值,感觉操作麻烦。
}
怎么样获取ChoiceGroup多选状态下的值呢?
连我这个做了几个小项目的程序员,今天都不知道怎么办了。
看了api文档不是很清晰,还是动手实践下吧。
看代码就知道了
boolean[] flags = new boolean[this.images.size()];
for(int i=0; i < flags.length; i++){
if(flags)
this.images.getString(i); //这里得的选中的值,感觉操作麻烦。
}
posted on 2007-08-30 19:35 3G视线 阅读(168) 评论(2) 编辑 收藏 引用 所属分类: j2me
[2] 腾挪资费提示过滤
来源: 互联网 发布时间: 2014-02-18
移动资费提示过滤
最近移动对网关进行改造,会弹出一个资费提示的wap页面,干扰了众多手机应用,手机网络游戏的正常运行,仅提供一个移动资费提示过滤的工具类代码,以抛砖引玉
使用例子
最近移动对网关进行改造,会弹出一个资费提示的wap页面,干扰了众多手机应用,手机网络游戏的正常运行,仅提供一个移动资费提示过滤的工具类代码,以抛砖引玉
package redduke.game.j2me.io;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
public class HttpUtil{
/*
* 缺省过滤器实例
*/
protected static HttpConnectionFilter filter=new HttpConnectionFilter()
{
public boolean accept(HttpConnection con) {
/* 资费提示wap页面长度=438+目的地URL字符串字节长度 */
return con!=null && con.getLength()!=438+con.getURL().getBytes().length;
}
};
/**
* 打开一个HttpConnection
* @param url
*/
public static HttpConnection open(final String url)
{
/* 一个HttpConnection的代理实现 */
return new HttpConnection()
{
/*
* 连接
*/
private javax.microedition.io.HttpConnection con;
/*
* 连接次数,超过次数则认为连接失败
*/
private int connectCount=0;
/*
* 输出缓冲
*/
private ByteArrayOutputStream baos=new ByteArrayOutputStream(1024);
/*
* 请求属性
*/
private Hashtable requestProperties=new Hashtable();
/*
* 请求方式
*/
private String method=GET;
/*
* 连接服务器
*/
private void connect()
{
try
{
if(this.con!=null)
this.con.close();
}
catch(Exception ex){}
try
{
this.con=(javax.microedition.io.HttpConnection)Connector.open(url);
this.con.setRequestMethod(this.method);
Enumeration propertyKeys=this.requestProperties.keys();
while(propertyKeys.hasMoreElements())
{
String propertyKey=(String)propertyKeys.nextElement();
String propertyValue=(String)requestProperties.get(propertyKey);
this.con.setRequestProperty(propertyKey,propertyValue);
}
}
catch(Exception ex)
{
this.con=null;
}
}
/*
* 确认连接
*/
private void ensureConnect()
{
while(this.con==null || filter!=null && !filter.accept(this.con))
{
if(connectCount>=5)
throw new RuntimeException("Connection failed");
connectCount++;
this.connect();
}
}
public long getDate() throws IOException {
ensureConnect();
return this.con.getDate();
}
public long getExpiration() throws IOException {
ensureConnect();
return this.con.getExpiration();
}
public String getFile() {
ensureConnect();
return this.con.getFile();
}
public String getHeaderField(String arg0) throws IOException {
ensureConnect();
return this.con.getHeaderField(arg0);
}
public String getHeaderField(int arg0) throws IOException {
ensureConnect();
return this.con.getHeaderField(arg0);
}
public long getHeaderFieldDate(String arg0, long arg1) throws IOException {
ensureConnect();
return this.con.getHeaderFieldDate(arg0, arg1);
}
public int getHeaderFieldInt(String arg0, int arg1) throws IOException {
ensureConnect();
return this.con.getHeaderFieldInt(arg0, arg1);
}
public String getHeaderFieldKey(int arg0) throws IOException {
ensureConnect();
return this.con.getHeaderFieldKey(arg0);
}
public String getHost() {
ensureConnect();
return this.con.getHost();
}
public long getLastModified() throws IOException {
ensureConnect();
return this.con.getLastModified();
}
public int getPort() {
ensureConnect();
return this.con.getPort();
}
public String getProtocol() {
ensureConnect();
return this.con.getProtocol();
}
public String getQuery() {
ensureConnect();
return this.con.getQuery();
}
public String getRef() {
ensureConnect();
return this.con.getRef();
}
public String getRequestMethod() {
ensureConnect();
return this.con.getRequestMethod();
}
public String getRequestProperty(String arg0) {
ensureConnect();
return this.con.getRequestProperty(arg0);
}
public int getResponseCode() throws IOException {
ensureConnect();
return this.con.getResponseCode();
}
public String getResponseMessage() throws IOException {
ensureConnect();
return this.con.getResponseMessage();
}
public String getURL() {
ensureConnect();
return this.con.getURL();
}
public void setRequestMethod(String arg0) throws IOException {
this.method=arg0;
}
public void setRequestProperty(String arg0, String arg1) throws IOException {
requestProperties.put(arg0, arg1);
}
public String getEncoding() {
ensureConnect();
return this.con.getEncoding();
}
public long getLength() {
ensureConnect();
return this.con.getLength();
}
public String getType() {
ensureConnect();
return this.con.getType();
}
public DataInputStream openDataInputStream() throws IOException {
ensureConnect();
return this.con.openDataInputStream();
}
public InputStream openInputStream() throws IOException {
ensureConnect();
return this.con.openInputStream();
}
public void close() throws IOException {
ensureConnect();
this.con.close();
}
public DataOutputStream openDataOutputStream() throws IOException {
return new DataOutputStream(baos);
}
public OutputStream openOutputStream() throws IOException {
return baos;
}
};
}
/*
* 设置过滤器,可设置自定义过滤器
*/
public static void setHttpConnectionFilter(HttpConnectionFilter filter)
{
HttpUtil.filter=filter;
}
/**
* 过滤器接口
*/
public static interface HttpConnectionFilter
{
boolean accept(HttpConnection con);
}
}
使用例子
HttpConnection con=HttpUtil.open("http:\\abc.com");
1 楼
ystt8283
2007-05-18
感谢楼主的贡献,有机会想和楼主交流一下QQ361607124
2 楼
redduke1202
2007-05-21
ps:缺省的过滤器中的关键数值438是经过测试得来的,这个过滤器实现比较简单,而且不需要读取内容下来进行判断,降低了信息流量,可根据具体应用自行实现HttpConnectionFilter接口,并设置
3 楼
cuilichen
2007-05-21
楼主在哪个省啊?不是全国的状况都是这样的吧?
4 楼
redduke1202
2007-05-22
在上海
5 楼
nomen
2007-05-22
protected static HttpConnectionFilter filter=new HttpConnectionFilter()
{
public boolean accept(HttpConnection con) {
/* 资费提示wap页面长度=438+目的地URL字符串字节长度 */
return con!=null && con.getLength()!=438+con.getURL().getBytes().length;
}
};
6 楼
ywg_2008
2007-05-25
请问,你这个HttpConnection con=HttpUtil.open("http:\\abc.com"); 放在哪儿,是不是我的过滤器就执行这段代码?谢谢
7 楼
lu_pp
2007-08-22
好像每个地方的大小不一样啊
8 楼
zyhighway
2007-08-25
其实简单的过滤方法是:在网络传送回来的数据流中,判断是否有你访问的网络地址数据串,如果有,就是资费页面,这时候再重新访问一次即可获得正确的数据。我的程序中就是这么做的,应该比较通用吧!
[3] think in java 汉语言文档
来源: 互联网 发布时间: 2014-02-18
think in java 中文文档
think in java 中文文档
think in java 中文文档
最新技术文章: