资 源 简 介
一款还不错的静态壁纸代码 核心代码:package com.example.wallpaperchange;import android.os.Bundle;import android.app.Activity;import android.app.AlarmManager;import android.app.PendingIntent;import android.app.Service;import android.content.Intent;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.Toast; public class MainActivity extends Activity { AlarmManager aManager; Button start,stop; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); start = (Button)findViewById(R.id.start); stop = (Button)findViewById(R.id.stop); aManager = (AlarmManager)getSystemService(Service.ALARM_SERVICE); //指定ChangeService组件 Intent intent = new Intent(MainActivity.this,ChangeService.class); //创建PendingIntent对象 final PendingIntent pi = PendingIntent.getService( MainActivity.this, 0, intent, 0); start.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub aManager.setRepeating(AlarmManager.RTC_WAKEUP, 0, 5000, pi); start.setEnabled(false); stop.setEnabled(true); Toast.makeText(MainActivity.this, "壁纸定时更换启动成功", 5000).show(); } }); stop.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub start.setEnabled(true); stop.setEnabled(false); aManager.cancel(pi); } }); } }