体育资讯网

您现在的位置是:首页 > 分类14 > 正文

分类14

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

hacker2022-07-14 17:59:37分类1477
本文目录一览:1、安卓天气预报源码,从网络获取获取信息那种的,求大神教教我2、

本文目录一览:

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

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

跪求基于安卓平台的天气预报系统的设计与实现的源代码???要没有乱码的,能在在模拟器上运行的。。。。

我做的项目中有从中国天气网获取的5日天气数据的,安卓天气预报app源码你要不要安卓天气预报app源码?因为目前处于功能设计阶段,界面不怎么美观,要后期才会美化!你如果有基础的话,我可以提供获取数据的代码,只要自己设计个界面,数据放上去显示就好。

求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天气预报源代码

我这边有 2227421573 不过是简单的实现天气预报,只能查看当天的天气信息, 自动定位到当前的城市,然后去查询天气信息的.

求andriod天气预报源码!!可以在eclipse运行的,不要走乱码的,感激不尽,拜托了联系方式

这个自己去下载。里面的天气接口已经过期,自己去网站申请一下

发表评论

评论列表

  • 晴枙疚爱(2022-07-14 23:46:59)回复取消回复

    sureTextView; private TextView lightTextView; private float currentTemperature=Float.NaN

  • 只酷初霁(2022-07-15 04:51:14)回复取消回复

    e protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setConte