主函数天气

Posted 天之骄子19

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了主函数天气相关的知识,希望对你有一定的参考价值。

package com.coolweather.android;

import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import static com.baidu.location.h.i.R;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getString("weather", null) != null) {
Intent intent = new Intent(this, WeatherActivity.class);
startActivity(intent);
finish();
}
else {
String weatherId="CN101110101";
Intent intent = new Intent(this, WeatherActivity.class);
intent.putExtra("weather_id", weatherId);
startActivity(intent);
finish();
}
}

}

以上是关于主函数天气的主要内容,如果未能解决你的问题,请参考以下文章