Android调用webservice实现手机归属查询

Android中的webservice调用方式与java中差异较大,经过查找些资料和例子,自己这边儿就做了个总结,写了个例子,谈不上原创(惭愧ing...),不过这方面的例子确实都大体相似,因为大家能写成博文的,发布成例子的,调用的接口大抵是网上公开的接口,如天气啊,手机号码段啊之类的,公司内部的接口,肯定是不能外透的,但是调用的方式确实一样,所以记录下来,方便大家研究,或者自己今后用到。

第一步,加入调用webservice的jar包,ksoap2-android-assembly-2.5.4-jar-with-dependencies.jar,下面会提供附件下载。

第二步,编辑activity_main.xml布局出效果图一所示效果,代码如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:orientation="vertical"
  4.     android:layout_width="fill_parent"
  5.     android:layout_height="fill_parent"
  6.     android:paddingTop="5dip"
  7.     android:paddingLeft="5dip"
  8.     android:paddingRight="5dip"
  9.     >
  10.     <TextView
  11.         android:layout_width="fill_parent"
  12.         android:layout_height="wrap_content"
  13.         android:text="手机号码(段):"
  14.     />
  15.     <EditText android:id="@+id/phone_sec"
  16.         android:layout_width="fill_parent"
  17.         android:layout_height="wrap_content"
  18.         android:inputType="textPhonetic"
  19.         android:singleLine="true"
  20.         android:hint="例如:1398547"
  21.     />
  22.     <Button android:id="@+id/query_btn"
  23.         android:layout_width="wrap_content"
  24.         android:layout_height="wrap_content"
  25.         android:layout_gravity="right"
  26.         android:text="查询"
  27.     />
  28.     <TextView android:id="@+id/result_text"
  29.         android:layout_width="wrap_content"
  30.         android:layout_height="wrap_content"
  31.         android:layout_gravity="center_horizontal|center_vertical"
  32.     />
  33. </LinearLayout>

 



微信扫描下方的二维码阅读本文

  • Android调用webservice实现手机归属查询已关闭评论
  • 185 views
    A+
发布日期:2016年03月30日  所属分类:JAVA