2015 a summary of the development of mobile Internet application software for higher vocational colleges

Source: Internet
Author: User
Tags http post


1. System Design (slight)

2. Program troubleshooting (slightly)

3. Function coding (can be organized)

UI layout (simple drag layout)

Network communication (JSON)

Normal process: According to the interface to go HTTP request, get JSON, send handler, receive data reflected to the interface.

Common POST Requests

/** * General POST request *  * @param URL *            interface address * @param params *            map Collection of parameters and values * @return JSON string */public static string Generalpost (String URL, map<string, string> params) {HttpPost request = new HttpPost (URL);//Create an HTTP POST request try {Jsono Bject jsonrequest = new Jsonobject (), if (params! = null) {for (String Key:params.keySet ()) {Jsonrequest.put (key, params. Get (key));}} Map-->json-->stringentitystringentity 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.P Rintstacktrace ();} Return "";}

/** * General JSON parsing * *  @param jsonstring   JSON data * *  @param keystring  Return key *             * @return */public String BAC Kjson (String jsonstring, String keystring) {string val = null;try {jsonobject jsonresponse = new Jsonobject (jsonstring); VA L = jsonresponse.getstring (keystring);} catch (Jsonexception e) {//TODO auto-generated catch Blocke.printstacktrace ();} return Val;}

Content push (Notification)

/** * Show notifications in status bar * Plus permissions <uses-permission android:name= "Android.permission.VIBRATE"/> * */private void Shownotifica tion () {//Create a Notificationmanager reference Notificationmanager Notificationmanager = (Notificationmanager) This.getsystemservice (Android.content.Context.NOTIFICATION_SERVICE);//define various properties of NOTIFICATION NOTIFICATION notification = new Notification (r.drawable.ic_launcher, "Test System", System.currenttimemillis ());//Flag_auto_cancel This notification can be cleared by the status bar's Purge button//flag_no_clear the notification cannot be cleared by the status bar's Purge button//flag_ongoing_event notification is placed in the running//flag_insistent Whether it has been performed, such as music has been playing , know user response notification.flags |= notification.flag_ongoing_event; Place this notice in the "ongoing", "running" Group of the notification bar notification.flags |= notification.flag_no_clear; Indicates that this notification is not cleared after clicking "Purge Notification" in the notification bar, and is often used with flag_ongoing_event notification.flags |= notification.flag_show_lights;// Default_all use all default values, such as sound, vibration, splash screen, etc.//default_lights Use default flash hint//default_sounds Use default alert sound//default_vibrate Use default phone shake, add <uses-permissionnotification.defaults = notification.default_lights;//Overlay Effect constantnotification.defaults=notification.default_lights| Notification.default_sound;notification.ledargb = COLOR.BLUE;NOTIFICATION.LEDONMS = 5000; Flash time, milliseconds//Set notification event message charsequence Contenttitle = "test system title"; Notification Bar title Charsequence ContentText = "test system contents"; Notification bar content Intent notificationintent = new Intent (mainactivity.this,mainactivity.class); Click on the notification to jump after the activitypendingintent contentitent = pendingintent.getactivity (this, 0,notificationintent, 0); Notification.setlatesteventinfo (This, contenttitle, contenttext,contentitent);// Pass the notification to notificationmanagernotificationmanager.notify (0, notification);} Delete notification private void Clearnotification () {//Start after delete we define the notification Notificationmanager Notificationmanager = ( Notificationmanager) This.getsystemservice (Notification_service); notificationmanager.cancel (0);}


Data Graph presentation (line chart)

Android paint is commonly used in third-party open source class Library, example: Click to open the link, very easy to use. But estimate the game, not necessarily to open source jar package, so you have to draw, more complex examples: Click to open the link

Local Database (Sqlite)

//Open or create Test.db database Sqlit Edatabase db = Openorcreatedatabase ("Test.db", context.mode_private, NULL);d b.execsql ("DROP TABLE IF EXISTS person");// Create Person Table Db.execsql ("CREATE TABLE person (_id INTEGER PRIMARY KEY autoincrement, name VARCHAR, age SMALLINT)");//entity class Perso n person = new Person ();p erson.name = "John";p Erson.age = 30;//Insert Data db.execsql ("INSERT INTO person VALUES (NULL,?,?)", NE W object[]{person.name, Person.age});//Add, update, and delete//db.executesql (String sql);//db.executesql (String sql, object[) Bindargs);//sql statement, and then the second parameter is the actual parameter set//query data cursor c = db.rawquery ("select * from person WHERE is 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 ();//close current database Db.close (); 


2015 a summary of the development of mobile Internet application software for higher vocational colleges

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.