Java tutorial
package org.cug.passenger; import java.util.ArrayList; import java.util.List; import org.cug.util.SQLiteTool; import org.cug.util.Settings; import org.cug.util.SysApplication; import org.cug.util.Tools; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import cn.jpush.android.api.JPushInterface; public class ShowDriverInfoActivity extends Activity { private TextView driverName; private TextView driverPhone; private TextView driverTime; private TextView license; private String driverNameStr; private String driverPhoneStr; private String driverTimeStr; private String licenseStr; private JSONObject extraJson = new JSONObject(); public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show_driver_info); // ? SysApplication.getInstance().addActivity(this); driverName = (TextView) findViewById(R.id.textView_drivername); driverPhone = (TextView) findViewById(R.id.textView_driverphone); driverTime = (TextView) findViewById(R.id.textView_drivertime); license = (TextView) findViewById(R.id.textView_license); if (Settings.TESTMODE) { driverName.setText(""); driverPhone.setText("13567893456"); driverTime.setText("20120112 1547"); license.setText("C780"); } else { if (getSendMessage()) { driverName.setText(driverNameStr); driverPhone.setText(driverPhoneStr); driverTime.setText(driverTimeStr); license.setText(licenseStr); } else { Tools.alert(getBaseContext(), "???"); } } } /** * ???? */ private boolean getSendMessage() { boolean isResult = false; getIntent(); Bundle bundle = getIntent().getExtras(); if (null != bundle) { bundle.getString(JPushInterface.EXTRA_MESSAGE); String extras = bundle.getString(JPushInterface.EXTRA_EXTRA); if (!ExampleUtilJPush.isEmpty(extras)) { try { extraJson = new JSONObject(extras); if (null != extraJson && extraJson.length() > 0) { driverNameStr = extraJson.getString("driverName"); driverPhoneStr = extraJson.getString("driverPhone"); driverTimeStr = extraJson.getString("driverTime"); licenseStr = extraJson.getString("license"); driverInfoIntoDb(); isResult = true; } } catch (JSONException e) { } } } return isResult; } /** * ??? */ public void driverInfoIntoDb() { ArrayList<String> content = new ArrayList<String>(); SQLiteTool sqLiteTool = new SQLiteTool("driverinfo"); content.add(driverNameStr); content.add(driverPhoneStr); content.add(driverTimeStr); content.add(licenseStr); sqLiteTool.insertContentToDrivers(content, "driverinfo"); } }