我是靠谱客的博主 饱满猫咪,最近开发中收集的这篇文章主要介绍android_天气预报,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

原址:http://blog.sina.com.cn/s/blog_778ad61301019fyb.html

 

package com.easytalent.android.meizu;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class MainActivity1 extends Activity{
 
 private TextView text_view = null;
 private static final String serviceNameSpace = "此处必须有最后一个反斜杠
 private static final String method = "getSupportCityDataset";
 private static final String url= "这个地址要正确
 private static final String SOAP_ACTION = "http://WebXml.com.cn/getSupportCityDataset";
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_front);
//  Intent intent = getIntent();
//  String value = intent.getStringExtra("testName");
  
  //获得返回的list数据
  Log.d("tag", getRequestData());
  String cityName = this.getRequestData();
  
  text_view = (TextView)findViewById(R.id.text_view);
  text_view.setText(cityName);
  }
 
 public String getRequestData(){
  try{
   
   SoapObject request = new SoapObject(serviceNameSpace,method);
   request.addProperty("theRegionCode","上海");//参数
   SoapSerializationEnvelope envelop;//序列化envelope
   envelop = new SoapSerializationEnvelope(SoapEnvelope.VER11);
   envelop.dotNet = true;
   envelop.setOutputSoapObject(request);
   envelop.bodyOut = request;
   envelop.encodingStyle = "UTF-8";
   
   HttpTransportSE httpClient = new HttpTransportSE(url);
   httpClient.debug = true;
   
   httpClient.call(SOAP_ACTION,envelop);
   
   if(envelop.getResponse() != null){
    SoapObject result = (SoapObject)envelop.getResponse();
    return envelop.bodyIn.toString();
   }
   return null;
   
  }catch(Exception e){
   e.printStackTrace();
  }
  return null;
 }
 
 

}

最后

以上就是饱满猫咪为你收集整理的android_天气预报的全部内容,希望文章能够帮你解决android_天气预报所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部