Big Bug Ban

兴趣 践行 创新

Android开发日志 得到手机版本号

 

今天弄日程的时候发现的..

2.0+ 和2.0- 的日程url不一样..

那么就需要得到手机的版本号..

其实android sdk里面是带有这个的

import android.os.Build;

这个里面不仅仅可以得到手机的版本号.还可以得到很多数据..

比如牌子..CPU芯片..等等参数

下表为sdk里面的说明

Constants
String BOARD The name of the underlying board, like "goldfish".
String BOOTLOADER The system bootloader version number.
String BRAND The brand (e.g., carrier) the software is customized for, if any.
String CPU_ABI The name of the instruction set (CPU type + ABI convention) of native code.
String CPU_ABI2 The name of the second instruction set (CPU type + ABI convention) of native code.
String DEVICE The name of the industrial design.
String DISPLAY A build ID string meant for displaying to the user
String FINGERPRINT A string that uniquely identifies this build.
String HARDWARE The name of the hardware (from the kernel command line or /proc).
String HOST
String ID Either a changelist number, or a label like "M4-rc20".
String MANUFACTURER The manufacturer of the product/hardware.
String MODEL The end-user-visible name for the end product.
String PRODUCT The name of the overall product.
String RADIO The radio firmware version number.
String TAGS Comma-separated tags describing the build, like "unsigned,debug".
long TIME
String TYPE The type of build, like "user" or "eng".
String UNKNOWN Value used for when a build property is unknown.
String USER

Written by princehaku

8月 19th, 2010 at 9:27 下午

Posted in Android

Tagged with ,

without comments

Android开发日志 androidkvb 正式版发布

 

之前的beta版因为gae不能访问的原因..

所以beta版 不论怎么输入..都会只显示登录超时

正式版已经转移了服务器..在哪里我就不说咯..

正式版相比测试版有以下修改

image

1.新的LOGO

image

2.进度显示优化 更加流畅

3.修正了原来的一个因为id固定造成的bug

4.优化了程序大小  现在只有17KB了

最后是下载地址

http://code.google.com/p/cdutkvb/downloads/detail?name=AndroidKVB-1.1.apk&can=2&q=#makechanges

image 二维码

另外如果您感兴趣…  请访问http://code.google.com/p/cdutkvb/ 有所有的svn记录以及下载

Written by princehaku

8月 17th, 2010 at 10:06 下午

Posted in Android,java

Tagged with ,

with 2 comments

貌似又被那个了..

 

GAE连不上教务处..

一直超时..

我还以为辅助选课可以..

结果是中间没加判断..

看样子都不能连了..

悲剧啊…

只好用其他方式了..比如..php..

这么多代码啊…

android版..j2me版现在如果连接..都会提示超时…

Written by princehaku

8月 15th, 2010 at 5:41 下午

Posted in java

Tagged with , , , , ,

without comments

Android开发日志 关于kvb..

 

今天把j2me版的搞出来了..

效果还行..但是没证书是个问题..要不停的按确认.

android版的呢..停留在beta版了..哎..

开学了找他们帮俺测试下…希望是可以用的..

最近公司的项目也很多啊…开学前弄完这些吧..

Written by princehaku

8月 15th, 2010 at 12:34 上午

Posted in Android,java

Tagged with ,

without comments

j2me StringTokenizer[存档]

 

/**
 * Copyright (c) 2010 princehaku
 * All right reserved.
 * Author princehaku
 * Site http://haku.hk
 * Created on : 2010-8-12, 21:54:50
 */

package net._3haku.util;

/**用于J2ME的分裂字符串函数
 *
 * @author princehaku
 */
public class StringTokenizer {
    /**源数据
     *
     */
    private String source;
    /**分离符
     *
     */
    private String sperator;
    /**当前解析到的位置
     *
     */
    private int pos;
    /**
     *
     * @param string
     * @param sperator
     */
    public StringTokenizer(String string, String sperator) {
        setSource(string);
        setSperator(sperator);
        pos=0;
    }
    /**是否还有分段
     * @return
     */
    public boolean hasMoreTokens() {
        //int pos1=getSource().indexOf(sperator,this.pos);
        if(pos>=getSource().length())
            return false;
        else
            return true;
    }
    /**下一个分段
     *
     * @return
     */
    public String nextToken() {
        int pos1=getSource().indexOf(sperator,this.pos);
        //如果找不到了..则将指针指向元素最大空间
        if(pos1==-1)
            pos1=getSource().length();
        int poslast=this.pos;
        this.pos=pos1+sperator.length();
        return getSource().substring(poslast, pos1);
    }
    private String getSource() {
        return source;
    }

    private void setSource(String source) {
        this.source = source;
    }
    
    private String getSperator() {
        return sperator;
    }

    private void setSperator(String sperator) {
        this.sperator = sperator;
    }


}

Written by princehaku

8月 15th, 2010 at 12:21 上午

Posted in java

Tagged with ,

with 2 comments

神速…

 

今天在淘宝上买了个东西..

10分钟后收到货了..

====================

为什么捏?…

因为店主居然在我附近..就一条街上!!!!

= =..

她直接给我打的电话..让我去取..

顺利到手…   运费也免了..

Written by princehaku

8月 14th, 2010 at 6:08 下午

Posted in things goes by

Tagged with

with 2 comments

它终于回来了.我的QQ机器人

 

之前服务器好像断开了..

现在它又回来了..泪奔啊~~~…

开学了还是把它做个一个开发包把….

Written by princehaku

8月 12th, 2010 at 7:50 上午

Posted in java

Tagged with ,

without comments

KVB android beta版 发布了!

 

本文已经参加   “首届 Google 暑期大学生博客分享大赛——2010 Android 篇”

为princehaku原创   如果您忘了我的地址  请使用google搜索  “Android开发日志”

这个耗时很久的东西终于弄完了..

白天在公司php..

晚上java…

先说说kvb是什么.

kvb呢  准确的说是cdutkvb

专门用于成都市理工大学的程序

它会根据你提供的教务处登陆账号和密码自动从教务处抓取到课表信息

然后解析成手机的日程  存入手机

也就是说  你只需要运行它一次  就可以把当学期的所有课程存入手机

附上一个流程说明图

以下是演示视频  (4M)

[flashvideo autostart=true file=/wp-content/uploads/2010/08/kvb.flv width=650 height=450 bufferlength=3 /]

这个是android 的 beta版..

因为模拟器上没有日程…所以不知道真机的效果如何..

所有源码都是公开的

您可以访问这里可以获取源码以及更新

android版下载地址 AndroidKVB-beta(点击下载)

(BETA版因服务器不能访问..现不提供下载 已经更新至正式版  请点击进入)

另外 ..j2me版会尽量在开学前完成…

Written by princehaku

8月 11th, 2010 at 12:52 下午

Posted in Android,java

Tagged with ,

with 10 comments

发现很多老图..站票,校庆,猝死..

 

上次开复博士来理工的票…当然不是我的票..我是工作人员.嗷嗷..两年了…时间真快啊….

这个是西北80校庆的…可惜当时我也没去

女朋友写的…当然..当时还不是我女朋友…也一年多了..时间真快啊.~

Written by princehaku

8月 10th, 2010 at 8:19 下午

Posted in things goes by

Tagged with

with 5 comments

Android开发日志 线程安全 小总结

 

本文已经参加   “首届 Google 暑期大学生博客分享大赛——2010 Android 篇”

为princehaku原创   如果您忘了我的地址  请使用google搜索  “Android开发日志”

今天弄了一天的这个软件…

最大的感受就是..

线程安全..既可靠又可恨,,

可恨的是每次都得重新写了Handler..不然不能调用..

比如alert

如果我在线程中直接调用了个alert..将会报错..

下面这个类是一个alert框体.

/**
 * Copyright (c) 2010 princehaku
 * All right reserved.
 * Author princehaku
 * Site http://haku.hk
 * Created on : 2010-8-8, 10:12:28
 */
package org.me.androidkvb;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

/**消息提示类
 *
 * @author princehaku
 */
public class Alert {

    /**资源
     *
     */
    private static Context res;

    Dialog alert;

    /**从上级资源中构建
     * res一般是当前活动的Activity
     * @param res
     */
    Alert(Context res) {
        this.res = res;
    }
    /**显示对话框
     *
     * @param title
     * @param message
     */
    public void show(String title,String message) {
        Message msg = new Message();
        Bundle ble = new Bundle();
        ble.putString("title", title);
        ble.putString("msg", message);
        msg.setData(ble);
        this.alertHandler.sendMessage(msg);
    }

    /**隐藏对话框
     *
     */
    public void destory() {
        if(alert!=null){
            alert.dismiss();
        }
    }
    /**隐含的方法
     * 显示对话框
     * @param info
     */
    private void alert(String title,String info) {
        if (alert != null) {
            alert.dismiss();
        }
        alert = new AlertDialog.Builder(res).setIcon(android.R.drawable.ic_dialog_alert).setTitle(title).setMessage(info).show();
    }
    /**Hander
     * 保证线程安全
     */
    public Handler alertHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            alert(msg.getData().getString("title"),msg.getData().getString("msg"));
            super.handleMessage(msg);
        }
    };
}

使用的时候如下

/**
 *
 * @author princehaku
 */
public class MainActivity extends Activity implements OnClickListener{
    Alert alert;
    public Alert getAlert(){
        if(alert==null)alert=new Alert(this);
        return alert;
    }
 public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
       Thread t=new Thread(){
        @Override
        public void run() {
                    getAlert().show("Please Wait","开始联网获取课表信息");
               }
        };
    t.start();
}

不仅仅是这个…只要非安全线程调用都得用Handler去处理

=================================================

哎…看来还得写很多…因为多线程的用户体验比单线程好..

如果超过5秒就会提示退出了..

so…coding…

另外…进度展示

已经可以解释出序列化的课表了..

也可以显示出来…还有具体解析时的进度  自己弄了个假的条形的进度条…

Written by princehaku

8月 8th, 2010 at 3:32 下午

Posted in Android

Tagged with ,

with 2 comments