并调用WebService的方法。
主要代码如下:
public class Connection
{
public static String Connect(String jklb,String xmlString)
{
// 命名空间
String nameSpace = "10.0.2.2:9080/sgclpt/services/sgptservice";
// 调用的方法名称
String methodName = "WriteObjectOut";
// EndPoint
String endPoint = "10.0.2.2:9080/sgclpt/services/sgptservice";
// SOAP Action
String soapAction =
"10.0.2.2:9080/sgclpt/services/sgptservice/WriteObjectOut";
// 指定WebService的命名空间和调用的方法名
SoapObject rpc = new SoapObject(nameSpace, methodName);
// 设置需调用WebService接口需要传入的两个参数mobileCode、userId
rpc.addProperty("xtlb", "01");
rpc.addProperty("jkid", jklb);
rpc.addProperty("key", "88ABB772F148C517031ED0275917098A");
rpc.addProperty("encrptXmlDoc", xmlString);
// 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.bodyOut = rpc;
// 设置是否调用的是dotNet开发的WebService
envelope.dotNet = false;
// 等价于envelope.bodyOut = rpc;
envelope.setOutputSoapObject(rpc);
//Log.e(TAG, "正确");
HttpTransportSE transport = new HttpTransportSE(endPoint);
try {
// 调用WebService
transport.call(soapAction, envelope);
//Log.e(TAG, "正确");
} catch (Exception e) {
e.printStackTrace();
//Log.e(TAG, "错误"); //若异常发生,在控制台输出"错误"
}
// 获取返回的数据
SoapObject object = (SoapObject) envelope.bodyIn;
// 获取返回的结果
String result = object.getProperty(0).toString();
return result;
}
5.4 快速报案的描述与实现
5.4.1 快速报案描述
用户可以在登录客户端后选择"快速报案"功能,在紧急情况下也可以,直接跳过登录,直接点击便可快速使用"快速报案"功能。
快速报案功能第一步要采集的信息便是交通事故相关责任人的基本信息,包括""和"电话号码",其中甲方信息和乙方信息是必填的,丙方信息是可选填的,如图5.5所示。
填写完毕后,点击保存,客户端便会通过网络上传信息到服务器端,服务器也会返回相应信息,来表示是否上传成功或遇到什么问题导致未上传成功,若上传成功,便会弹出如图5.6所示信息。
图5.5 快速报案第一步采集信息
图5.6 信息上传成功并跳转界面
按提示,现在用户应当从前向后拍摄事故场景,若点击拍照,则Android将调用手机相机进行拍照,如图5.7所示。
图5.7 Android调用相机进行拍照
拍照完成,客户端将上传图片至服务器,服务器也会返回相应信息,来表示是否上传成功或遇到什么问题导致未上传成功,若上传成功,便会弹出如图5.8所示信息。
图5.8 上传图片信息成功并跳转界面
下一步依旧是按照提示进行拍照,下面客户端会依次要求用户拍摄甲方车辆受损部位、乙方车辆受损部位、丙方车辆受损部位(若有的话)。如图5.9-图5.10所示,当然,若某车辆无受损情况,则可以直接点击下一步,系统将自动跳转下一步界面。
图5.9 拍摄甲方车辆碰撞部位
图5.10 拍摄乙方车辆碰撞部位
拍摄完现场事故情况和车辆碰撞情况之后,系统会提示用户拍摄自己的驾驶证以及对方的驾驶证,同时填写自己和对方所购买过的车险,若双方已明确协商好是谁的责任,则在下拉选项条中选择各自所负责任情况,如双方无法协调,则选择"无法认定",如图5.11-图5.12所示。
图5.11 拍摄甲方驾驶证
图5.12 拍摄乙方驾驶证
拍摄完双方的驾驶证后,系统会自动跳转回功能主界面。如图5.13所示。
图5.13 拍摄驾驶证成功跳回功能主界面
5.4.2 主要代码实现
public class AcciPeople extends Activity {
String valuesString=new String();//定义用于传递事故编号的全局变量
private Spinner spin_area;
private EditText one_name=null;
private EditText one_phone=null;
private EditText two_name=null;
private EditText two_phone=null;
private EditText three_name=null;
private EditText three_phone=null;
private Button bt_save;
private Button bt_clear;
StringBuffer buffer = new StringBuffer();
String xmlString=new String();
// private myApplication mAppInstance; //全局变量类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_acci_people);
initializeViews();
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
setDateTime();
setTimeOfDay();
spin_area= (Spinner) findViewById(R.id.spin_area);
one_name= (EditText) findViewById(R.id.one_name);
one_phone= (EditText) findViewById(R.id.one_phone);
two_name= (EditText) findViewById(R.id.two_name);
two_phone= (EditText) findViewById(R.id.two_phone);
three_name= (EditText) findViewById(R.id.three_name);
three_phone= (EditText) findViewById(R.id.three_phone);
bt_save=(Button)this.findViewById(R.id.bt_save);
bt_clear=(Button)this.findViewById(R.id.bt_clear);
bt_save.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//以下为编辑xml格式的stringbuffer
buffer.append("");
buffer.append("
");
buffer.append("");
buffer.append("");
buffer.append("A");
buffer.append("");
buffer.append("");
buffer.append(one_name.getText());
buffer.append("");
buffer.append("");
buffer.append(one_phone.getText());
buffer.append("");
buffer.append("");
buffer.append("B");
buffer.append("");
buffer.append("");
buffer.append(two_name.getText());
buffer.append("");
buffer.append("");
buffer.append(two_phone.getText());
buffer.append("");
//判断是否有事故人员丙方,没有的话则只上传事故人员甲方和乙方
if(!"".equals(three_name.getText().toString().trim()))
{
buffer.append("");
buffer.append("C");
buffer.append("");
buffer.append("");
buffer.append(three_name.getText());
buffer.append("");
buffer.append("");
buffer.append(three_phone.getText());
buffer.append("");
}
String ar
上一篇:安卓操作系统下嵌入式图像分析软件开发与移植---毕业论文
下一篇:试论APP广告在手机中的应用