android天气预报app源码(安卓简单天气预报app源码)

今天给各位分享android天气预报app源码的知识,其中也会对安卓简单天气预报app源码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

安卓天气预报源码,从网络获取获取信息那种的,求大神教教我

你要求太多了,除非是干这行的且有相关项目。即使如此也不会轻易给你。既然你是答辩,那么可以给你大概说下都是什么东西。关键就是一个后台service,设置成24小时一次访问网络,获取数据,至于天气预报信息,是从服务器请求下来的数据。其他的就是把这些数据适配到界面的问题了。‘ 建议你去百度上搜下: 1,Activity组件 2,service组件 3,webService 4,Adapter 当让,以上都是安卓相关。 既然是毕业设计,就花点时间看下吧。记得当时我也选个自己不怎么会的项目,然后钻了一段时间,最后毕业答辩虽然说的不好,可是都是自己的东西,老师们也知道大学情况,看到有人能自己努力不去抄袭,也很感动的给了好评。我谢谢那些令人尊敬的老师给我的鼓励。加油吧... ...

android天气预报app源码(安卓简单天气预报app源码),android天气预报app源码,源码,信息,百度,第1张

怎样获取当前的城市,并获得天气 android源码

名称:265天气根据IP自动获得当地的天气情况 代码:iframe src="weather/weather/Weather/news_new/inc/ss258/cgi-bin/news_weather_search?city=厦门" allowTransparency="true"/iframe 说明 :这种适合于在网页的正栏插入。上面的城市可以自定,比如厦门可改成别的。定制的方法是修改我代码中标红的 名称。这里比较简单,直接用汉字改就行了。比如是福州的,你就直接把“厦门”改成福州就行。名称:QQ天气预报代码(四) 代码 :iframe width=160 height=230 frameborder=0 scrolling=NO src=appnews/cgi-bin/news_qq_search?city=南昌/iframe 名称:QQ天气预报代码(五) 代码 :iframe src="appnews/cgi-bin/news_qq_search?city=南昌" frameborder="0" width="160" scrolling="no" height="230"/iframe

求Android天气预报的开发源代码

package com.nrzc.weatherstation;

import android.content.Context;

import android.hardware.Sensor;

import android.hardware.SensorEvent;

import android.hardware.SensorEventListener;

import android.hardware.SensorManager;

import android.os.Bundle;

import android.support.v7.app.AppCompatActivity;

import android.widget.TextView;

import java.util.Timer;

import java.util.TimerTask;

/**

* 环境传感器

* 气象站

*/

public class MainActivity extends AppCompatActivity {

private SensorManager sensorManager;

private TextView temperatureTextView;

private TextView pressureTextView;

private TextView lightTextView;

private float currentTemperature=Float.NaN;

private float currentPressure=Float.NaN;

private float currentLight=Float.NaN;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

init();

Timer updateTimer=new Timer("weatherUpdate");

updateTimer.scheduleAtFixedRate(new TimerTask() {

@Override

public void run() {

updateGUI();

}

},0,1000);

}

private void init(){

temperatureTextView=(TextView)findViewById(R.id.temperature);

pressureTextView=(TextView)findViewById(R.id.pressure);

lightTextView=(TextView)findViewById(R.id.light);

sensorManager=(SensorManager)getSystemService(Context.SENSOR_SERVICE);

}

private final SensorEventListener tempSensorEventListener=new SensorEventListener() {

@Override

public void onSensorChanged(SensorEvent event) {

currentTemperature=event.values[0];

}

@Override

public void onAccuracyChanged(Sensor sensor, int accuracy) {

}

};

private final SensorEventListener pressureSensorEventListener=new SensorEventListener() {

@Override

public void onSensorChanged(SensorEvent event) {

currentPressure=event.values[0];

}

@Override

public void onAccuracyChanged(Sensor sensor, int accuracy) {

}

};

private final SensorEventListener lightSensorEventListener=new SensorEventListener() {

@Override

public void onSensorChanged(SensorEvent event) {

currentLight=event.values[0];

}

@Override

public void onAccuracyChanged(Sensor sensor, int accuracy) {

}

};

@Override

protected void onResume() {

super.onResume();

Sensor lightSensor=sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);

if (lightSensor!=null)

sensorManager.registerListener(lightSensorEventListener,

lightSensor,

SensorManager.SENSOR_DELAY_NORMAL);

else

lightTextView.setText("Light Sensor Unavailable");

Sensor pressureSensor=sensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE);

if (pressureSensor!=null)

sensorManager.registerListener(pressureSensorEventListener,

pressureSensor,SensorManager.SENSOR_DELAY_NORMAL);

else

pressureTextView.setText("Barometer Unavailable");

Sensor temperatureSensor=sensorManager.getDefaultSensor(Sensor.TYPE_AMBIENT_TEMPERATURE);

if (temperatureSensor!=null)

sensorManager.registerListener(tempSensorEventListener,

temperatureSensor,

SensorManager.SENSOR_DELAY_NORMAL);

else

temperatureTextView.setText("Thermometer Unavailable");

}

@Override

protected void onPause() {

sensorManager.unregisterListener(pressureSensorEventListener);

sensorManager.unregisterListener(tempSensorEventListener);

sensorManager.unregisterListener(lightSensorEventListener);

super.onPause();

}

private void updateGUI(){

runOnUiThread(new Runnable() {

@Override

public void run() {

if(!Float.isNaN(currentPressure)){

pressureTextView.setText(currentPressure+"hPa");

pressureTextView.invalidate();

}

if (!Float.isNaN(currentLight)){

String lightStr="Sunny";

if (currentLight=SensorManager.LIGHT_CLOUDY)

lightStr="night";

else if (currentLight=SensorManager.LIGHT_OVERCAST)

lightStr="Cloudy";

else if (currentLight=SensorManager.LIGHT_SUNLIGHT)

lightStr="Overcast";

lightTextView.setText(lightStr);

lightTextView.invalidate();

}

if (!Float.isNaN(currentTemperature)){

temperatureTextView.setText(currentTemperature+"C");

temperatureTextView.invalidate();

}

}

});

}

}

android 做一个天气预报的步骤

安卓编程设计很多方面,非常复杂,需要系统的学习才可以,这里以一个简单的天气预报app编程为例:

public class WebServiceUtil

{

// 定义Web Service的命名空间

static final String SERVICE_NS = "";

// 定义Web Service提供服务的URL

static final String SERVICE_URL = "";

public static List getProvinceList()

{

// 需要调用的方法名(获得本天气预报Web Services支持的洲、国内外省份和城市信息)

String methodName = "getRegionProvince";

// 创建HttpTransportSE传输对象

HttpTransportSE httpTranstation = new HttpTransportSE(SERVICE_URL);

httpTranstation.debug = true;

// 使用SOAP1.1协议创建Envelop对象

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(

SoapEnvelope.VER11);

// 实例化SoapObject对象

SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);

envelope.bodyOut = soapObject;

// 设置与.Net提供的Web Service保持较好的兼容性

envelope.dotNet = true;

try

{

// 调用Web Service

httpTranstation.call(SERVICE_NS + methodName, envelope);

if (envelope.getResponse() != null)

{

// 获取服务器响应返回的SOAP消息

SoapObject result = (SoapObject) envelope.bodyIn;

SoapObject detail = (SoapObject) result.getProperty(methodName

+ "Result");

// 解析服务器响应的SOAP消息。

return parseProvinceOrCity(detail);

}

} catch (Exception e)

{

e.printStackTrace();

}

return null;

}

public static List getCityListByProvince(String province)

{

// 需要调用的方法名(获得本天气预报Web Services支持的城市信息,根据省份查询城市集合:带参数)

String methodName = "getSupportCityString";

HttpTransportSE httpTranstation = new HttpTransportSE(SERVICE_URL);

httpTranstation.debug = true;

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(

SoapEnvelope.VER11);

SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);

soapObject.addProperty("theRegionCode", province);

envelope.bodyOut = soapObject;

envelope.dotNet = true;

try

{

// 调用Web Service

httpTranstation.call(SERVICE_NS + methodName, envelope);

if (envelope.getResponse() != null)

{

// 获取服务器响应返回的SOAP消息

SoapObject result = (SoapObject) envelope.bodyIn;

SoapObject detail = (SoapObject) result.getProperty(methodName

+ "Result");

// 解析服务器响应的SOAP消息。

return parseProvinceOrCity(detail);

}

} catch (Exception e)

{

e.printStackTrace();

}

return null;

}

private static List parseProvinceOrCity(SoapObject detail)

{

ArrayList result = new ArrayList();

for (int i = 0; i detail.getPropertyCount(); i++)

{

String str = detail.getProperty(i).toString();

// 解析出每个省份

result.add(str.split(",")[0]);

}

return result;

}

public static SoapObject getWeatherByCity(String cityName)

{

// 根据城市或地区名称查询获得未来三天内天气情况、现在的天气实况、天气和生活指数

String methodName = "getWeather";

HttpTransportSE httpTranstation = new HttpTransportSE(SERVICE_URL);

httpTranstation.debug = true;

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(

SoapEnvelope.VER11);

SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);

soapObject.addProperty("theCityCode", cityName);

envelope.bodyOut = soapObject;

envelope.dotNet = true;

try

{

// 调用Web Service

httpTranstation.call(SERVICE_NS + methodName, envelope);

if (envelope.getResponse() != null)

{

// 获取服务器响应返回的SOAP消息

SoapObject result = (SoapObject) envelope.bodyIn;

SoapObject detail = (SoapObject) result.getProperty(methodName

+ "Result");

// 解析服务器响应的SOAP消息。

return detail;

}

} catch (Exception e)

{

e.printStackTrace();

}

return null;

}

}

android天气预报app源码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于安卓简单天气预报app源码、android天气预报app源码的信息别忘了在本站进行查找喔。


【免责声明】:

本站所发布的一切资源仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。

【关于转载】:

本站尊重互联网版权体系,本站部分图片、文章大部分转载于互联网、所有内容不代表本站观点、不对文章中的任何观点负责、转载的目的只用于给网民提供信息阅读,无任何商业用途,所有内容版权归原作者所有
如本站(文章、内容、图片、视频)任何资料有侵权,先说声抱歉;麻烦您请联系请后台提交工单,我们会立即删除、维护您的权益。非常感谢您的理解。

【附】:

二○○二年一月一日《计算机软件保护条例》第十七条规定:为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬!鉴于此,也希望大家按此说明研究软件!

注:本站资源来自网络转载,版权归原作者和公司所有,如果有侵犯到您的权益,请第一时间联系我们处理!

-----------------------------------------------------------------------------------------------------------

【版权声明】:

一、本站致力于为源码爱好者提供国内外软件开发技术和软件共享,着力为用户提供优资资源。
二、本站提供的源码下载文件为网络共享资源,请于下载后的24小时内删除。如需体验更多乐趣,还请支持正版。
三、如有内容侵犯您的版权或其他利益的,请编辑邮件并加以说明发送到站长邮箱。站长会进行审查之后,情况属实的会在三个工作日内为您删除。
-----------------------------------------------------------------------------------------------------------


内容投诉
源码村资源网 » android天气预报app源码(安卓简单天气预报app源码)
您需要 登录账户 后才能发表评论

发表评论

欢迎 访客 发表评论