基本信息
源码名称:android手机号码属地app源码
源码大小:1.76M
文件格式:.zip
开发语言:Java
更新时间:2020-01-03
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

可以输入手机号码查询归属地


package com.example.webserver;

import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {
	EditText editText;
	Button button;
	TextView textView;
	final static String SERVICE_NS = "http://WebXml.com.cn/";;
	final static String SERVICE_URL= "http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx";
	
	Handler handler=new Handler(){
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case 0x123:
				textView.setText(msg.obj.toString());
				break;

			default:
				break;
			}
		}
	};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        editText=(EditText)findViewById(R.id.editText);
        button=(Button)findViewById(R.id.button1);
        textView=(TextView)findViewById(R.id.textView1);
        button.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				final String methodName = "getMobileCodeInfo";
				final HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);
				ht.debug=true;
				final SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
				SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);
				soapObject.addProperty("mobileCode",editText.getText().toString().trim());
				envelope.bodyOut=soapObject;
				envelope.dotNet=true;
				new Thread(){
					public void run() {
						try {
							ht.call(SERVICE_NS methodName, envelope);
							Log.i("call",SERVICE_NS methodName);
							if (envelope.getResponse()!=null) {
								SoapObject result=(SoapObject)envelope.bodyIn;
								String detail1=result.getProperty(0).toString();
								Log.i("detail", detail1);
								Message msg=new Message();
								msg.what=0x123;
								msg.obj=detail1;
								handler.sendMessage(msg);
								
							}
						} catch (IOException e) {
							// TODO: handle exception
							e.printStackTrace();
						} catch (XmlPullParserException e) {
							// TODO 自动生成的 catch 块
							e.printStackTrace();
						}
					};
				}.start();
				
			}
		});
        
        
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}