Skip to content

uweii/LoveRecord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LoveRecord

一个恋爱的计时桌面插件

截图

主界面

设置日期

桌面效果


***
用到知识:service, broadcastreceiver, widget布局,图片解析处理,DatePicker,TimePicker
Sharepreference,等 --------
使用widget写的一个简单计时插件。
点击设置图片button后,实际是启动打开图库的intent。startActivityForResult。拿到选择的图片对应的uri后
便将图片显示这个ImageView中,其中涉及到压缩图片,因为图片内存可能太大,然后导致oom。
------
private Bitmap getSmallBitmap(String path){
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(path,options);
float w = options.outWidth;
float h = options.outHeight;
options.inJustDecodeBounds = false;
float ww = 240f;
float hh = 400f;
int scale = Math.max(Math.round(w/ww),Math.round(h/hh));
options.inSampleSize = scale;
return BitmapFactory.decodeFile(path,options);
}
  返回一个较小的图片。
  然后启动service用来计时更新。
  注意
  @Override
public int onStartCommand(Intent intent, int flags, int startId) {
flags = START_STICKY; //防止因内存不足而销毁service,所以设置成START_STICKY,当因内存不足销毁后会自动启动
return super.onStartCommand(intent, flags, startId);
}
CSDN地址 http://blog.csdn.net/dummyo/article/details/79334068

About

一个恋爱的计时桌面插件

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages