2015高职院校移动互联网应用软件开发赛准备小结
来源:互联网 发布:千岛片淘宝叫什么 编辑:程序博客网 时间:2024/04/30 19:49
http://blog.csdn.net/f5647/article/details/45668265
1.系统设计(略)
2.程序排错(略)
3.功能编码(可以整理)
Ui布局 (简单的 拖动布局)
网络通信(JSON)
正常流程:根据接口去http请求,得到JSON,发送Handler, 接收数据反映到界面。
通用的post请求
-
-
-
-
-
-
-
-
-
- public static String generalPost(String url, Map<String, String> params) {
- HttpPost request = new HttpPost(url);
-
- try {
- JSONObject jsonRequest = new JSONObject();
- if (params != null) {
- for (String key : params.keySet()) {
- jsonRequest.put(key, params.get(key));
- }
- }
-
- StringEntity se = new StringEntity(jsonRequest.toString());
- request.setEntity(se);
- HttpResponse httpResponse = new DefaultHttpClient()
- .execute(request);
- String retSrc = EntityUtils.toString(httpResponse.getEntity());
- return retSrc;
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- } catch (ClientProtocolException e) {
- e.printStackTrace();
- } catch (ParseException e) {
- e.printStackTrace();
- } catch (JSONException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return "";
- }
-
-
-
-
-
-
-
-
-
- public String backJson(String jsonString, String keyString) {
- String val = null;
- try {
- JSONObject jsonResponse = new JSONObject(jsonString);
- val = jsonResponse.getString(keyString);
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- return val;
- }
内容推送(Notification)
-
-
-
-
-
-
- private void showNotification() {
-
- NotificationManager notificationManager = (NotificationManager) this
- .getSystemService(android.content.Context.NOTIFICATION_SERVICE);
-
-
- Notification notification = new Notification(R.drawable.ic_launcher,
- "测试系统", System.currentTimeMillis());
-
-
-
-
- notification.flags |= Notification.FLAG_ONGOING_EVENT;
- notification.flags |= Notification.FLAG_NO_CLEAR;
- notification.flags |= Notification.FLAG_SHOW_LIGHTS;
-
-
-
-
- notification.defaults = Notification.DEFAULT_LIGHTS;
-
-
- notification.ledARGB = Color.BLUE;
- notification.ledOnMS = 5000;
-
-
- CharSequence contentTitle = "测试系统标题";
- CharSequence contentText = "测试系统内容";
- Intent notificationIntent = new Intent(MainActivity.this,
- MainActivity.class);
- PendingIntent contentItent = PendingIntent.getActivity(this, 0,
- notificationIntent, 0);
- notification.setLatestEventInfo(this, contentTitle, contentText,
- contentItent);
-
-
- notificationManager.notify(0, notification);
- }
-
-
- private void clearNotification() {
-
- NotificationManager notificationManager = (NotificationManager) this
- .getSystemService(NOTIFICATION_SERVICE);
- notificationManager.cancel(0);
-
- }
数据图表展现(折线图)
android画图 常用的是第三方常用的开源类库,例子:点击打开链接, 非常简单好用。但是估计比赛时,不一定会给开源jar包,所以得自己画图,比较复杂 例子:点击打 开链接
本地数据库(Sqlite)
-
- SQLiteDatabase db = openOrCreateDatabase("test.db", Context.MODE_PRIVATE, null);
- db.execSQL("DROP TABLE IF EXISTS person");
-
- db.execSQL("CREATE TABLE person (_id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR, age SMALLINT)");
-
- Person person = new Person();
- person.name = "john";
- person.age = 30;
-
- db.execSQL("INSERT INTO person VALUES (NULL, ?, ?)", new Object[]{person.name, person.age});
-
-
-
-
- Cursor c = db.rawQuery("SELECT * FROM person WHERE age >= ?", new String[]{"33"});
- while (c.moveToNext()) {
- int _id = c.getInt(c.getColumnIndex("_id"));
- String name = c.getString(c.getColumnIndex("name"));
- int age = c.getInt(c.getColumnIndex("age"));
- Log.i("db", "_id=>" + _id + ", name=>" + name + ", age=>" + age);
- }
- c.close();
-
-
-
- db.close();