2015高职院校移动互联网应用软件开发赛准备小结

来源:互联网 发布:千岛片淘宝叫什么 编辑:程序博客网 时间:2024/06/11 13:55

http://blog.csdn.net/f5647/article/details/45668265


1.系统设计(略)

2.程序排错(略)

3.功能编码(可以整理)

Ui布局 (简单的 拖动布局)

网络通信(JSON)

       正常流程:根据接口去http请求,得到JSON,发送Handler, 接收数据反映到界面。

       通用的post请求

[java] view plain copy
  1. /** 
  2.      * 通用的post请求 
  3.      *  
  4.      * @param url 
  5.      *            接口地址 
  6.      * @param params 
  7.      *            传参数和值的map集合 
  8.      * @return json 字符串 
  9.      */  
  10.     public static String generalPost(String url, Map<String, String> params) {  
  11.         HttpPost request = new HttpPost(url);  
  12.         // 创建HTTP POST请求  
  13.         try {  
  14.             JSONObject jsonRequest = new JSONObject();  
  15.             if (params != null) {  
  16.                 for (String key : params.keySet()) {  
  17.                     jsonRequest.put(key, params.get(key));  
  18.                 }  
  19.             }  
  20.             // map-->json-->stringentity  
  21.             StringEntity se = new StringEntity(jsonRequest.toString());  
  22.             request.setEntity(se);  
  23.             HttpResponse httpResponse = new DefaultHttpClient()  
  24.                     .execute(request);  
  25.             String retSrc = EntityUtils.toString(httpResponse.getEntity());  
  26.             return retSrc;  
  27.         } catch (UnsupportedEncodingException e) {  
  28.             e.printStackTrace();  
  29.         } catch (ClientProtocolException e) {  
  30.             e.printStackTrace();  
  31.         } catch (ParseException e) {  
  32.             e.printStackTrace();  
  33.         } catch (JSONException e) {  
  34.             e.printStackTrace();  
  35.         } catch (IOException e) {  
  36.             e.printStackTrace();  
  37.         }  
  38.         return "";  
  39.     }  

[java] view plain copy
  1. /** 
  2.      * 通用JSON解析 
  3.      *  
  4.      * @param jsonString   JSON数据 
  5.      *  
  6.      * @param keyString  返回key 
  7.      *             
  8.      * @return 
  9.      */  
  10.     public String backJson(String jsonString, String keyString) {  
  11.         String val = null;  
  12.         try {  
  13.             JSONObject jsonResponse = new JSONObject(jsonString);  
  14.             val = jsonResponse.getString(keyString);  
  15.         } catch (JSONException e) {  
  16.             // TODO Auto-generated catch block  
  17.             e.printStackTrace();  
  18.         }  
  19.         return val;  
  20.     }  

内容推送(Notification)

[java] view plain copy
  1. /** 
  2.      * 在状态栏显示通知 
  3.      *  
  4.      * 加权限 <uses-permission android:name="android.permission.VIBRATE" /> 
  5.      *  
  6.      */  
  7.     private void showNotification() {  
  8.         // 创建一个NotificationManager的引用  
  9.         NotificationManager notificationManager = (NotificationManager) this  
  10.                 .getSystemService(android.content.Context.NOTIFICATION_SERVICE);  
  11.   
  12.         // 定义Notification的各种属性  
  13.         Notification notification = new Notification(R.drawable.ic_launcher,  
  14.                 "测试系统", System.currentTimeMillis());  
  15.         // FLAG_AUTO_CANCEL 该通知能被状态栏的清除按钮给清除掉  
  16.         // FLAG_NO_CLEAR 该通知不能被状态栏的清除按钮给清除掉  
  17.         // FLAG_ONGOING_EVENT 通知放置在正在运行  
  18.         // FLAG_INSISTENT 是否一直进行,比如音乐一直播放,知道用户响应  
  19.         notification.flags |= Notification.FLAG_ONGOING_EVENT; // 将此通知放到通知栏的"Ongoing"即"正在运行"组中  
  20.         notification.flags |= Notification.FLAG_NO_CLEAR; // 表明在点击了通知栏中的"清除通知"后,此通知不清除,经常与FLAG_ONGOING_EVENT一起使用  
  21.         notification.flags |= Notification.FLAG_SHOW_LIGHTS;  
  22.         // DEFAULT_ALL 使用所有默认值,比如声音,震动,闪屏等等  
  23.         // DEFAULT_LIGHTS 使用默认闪光提示  
  24.         // DEFAULT_SOUNDS 使用默认提示声音  
  25.         // DEFAULT_VIBRATE 使用默认手机震动,需加上<uses-permission  
  26.         notification.defaults = Notification.DEFAULT_LIGHTS;  
  27.         // 叠加效果常量  
  28.         // notification.defaults=Notification.DEFAULT_LIGHTS|Notification.DEFAULT_SOUND;  
  29.         notification.ledARGB = Color.BLUE;  
  30.         notification.ledOnMS = 5000// 闪光时间,毫秒  
  31.   
  32.         // 设置通知的事件消息  
  33.         CharSequence contentTitle = "测试系统标题"// 通知栏标题  
  34.         CharSequence contentText = "测试系统内容"// 通知栏内容  
  35.         Intent notificationIntent = new Intent(MainActivity.this,  
  36.                 MainActivity.class); // 点击该通知后要跳转的Activity  
  37.         PendingIntent contentItent = PendingIntent.getActivity(this0,  
  38.                 notificationIntent, 0);  
  39.         notification.setLatestEventInfo(this, contentTitle, contentText,  
  40.                 contentItent);  
  41.   
  42.         // 把Notification传递给NotificationManager  
  43.         notificationManager.notify(0, notification);  
  44.     }  
  45.   
  46.     // 删除通知  
  47.     private void clearNotification() {  
  48.         // 启动后删除之前我们定义的通知  
  49.         NotificationManager notificationManager = (NotificationManager) this  
  50.                 .getSystemService(NOTIFICATION_SERVICE);  
  51.         notificationManager.cancel(0);  
  52.   
  53.     }  


数据图表展现(折线图)

          android画图 常用的是第三方常用的开源类库,例子:点击打开链接, 非常简单好用。但是估计比赛时,不一定会给开源jar包,所以得自己画图,比较复杂 例子:点击打            开链接

本地数据库(Sqlite)

[java] view plain copy
  1. //打开或创建test.db数据库  
  2.             SQLiteDatabase db = openOrCreateDatabase("test.db", Context.MODE_PRIVATE, null);  
  3.             db.execSQL("DROP TABLE IF EXISTS person");  
  4.             //创建person表  
  5.             db.execSQL("CREATE TABLE person (_id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR, age SMALLINT)");  
  6.             //实体类  
  7.             Person person = new Person();  
  8.             person.name = "john";  
  9.             person.age = 30;  
  10.             //插入数据  
  11.             db.execSQL("INSERT INTO person VALUES (NULL, ?, ?)"new Object[]{person.name, person.age});  
  12.             //添加、更新和删除  
  13. //          db.executeSQL(String sql);  
  14. //          db.executeSQL(String sql, Object[] bindArgs);//sql语句,然后第二个参数是实际的参数集           
  15.             //查询数据  
  16.             Cursor c = db.rawQuery("SELECT * FROM person WHERE age >= ?"new String[]{"33"});  
  17.             while (c.moveToNext()) {  
  18.                 int _id = c.getInt(c.getColumnIndex("_id"));  
  19.                 String name = c.getString(c.getColumnIndex("name"));  
  20.                 int age = c.getInt(c.getColumnIndex("age"));  
  21.                 Log.i("db""_id=>" + _id + ", name=>" + name + ", age=>" + age);  
  22.             }  
  23.             c.close();  
  24.               
  25.               
  26.             //关闭当前数据库  
  27.             db.close();  


原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 小米手机安卓系统耗电量大怎么办? 苹果5s充不进去电怎么办 苹果手机6s返回键失灵怎么办 本人被骗同时被利用骗了别人怎么办 京东取消订单后货到了该怎么办 京东电信日租卡流量顶置了怎么办 苹果6s进水后闪光灯不亮怎么办 华为手机情景义停车事项过期怎么办 拼多多付款后商品下架了怎么办 淘宝上买化妆品买到假货了怎么办 找苹果官网解id发票丢了怎么办 客人已交订金但要取消宴席怎么办 京东买的小米电视碎屏了怎么办 京东购买的电视碎屏了怎么办 淘宝上买手机不能用不给退怎么办 天猫申请退货退款卖家不处理怎么办 在淘宝买到货到付款的假苹果怎么办 跟朋友买手机买到假货怎么办 在淘宝网上买到不合格的产品怎么办 淘宝打假师打了我的店铺怎么办 收藏品公司关门跑路员工怎么办 客户快递签收后说货物短缺怎么办 京东商城买东西商家不换货怎么办 在商场买东西过几天就降价了怎么办 天猫买东西不退货不退款怎么办 买买8p美版的怎么办 京东金条银行卡被冻结还不了怎么办 在瑞士刚买的浪琴手表不走了怎么办 刚买的手表表镜有划痕 怎么办 唯品会上买的手表有质量问题怎么办 我买的对方材料没开票给我怎么办 给对方修完车车主不给发票怎么办 买苹果手机花呗额度不够怎么办 苹果手机用别人的手机卡激活怎么办 小米商城花呗分期额度不够怎么办 淘宝已经形成订单商家不发货怎么办 小米商城退款后又想买了怎么办 淘宝退货退款后不想退了怎么办 在转转的商品被屏了怎么办 不懂如何挑选适合自己的衣服怎么办 淘宝购买商品给顾客造成损失怎么办