代码改变世界

无限循环,自动滚动,兼容PageIndicator的ViewPager

2014-02-13 11:52 by 默契., 2481 阅读, 0 推荐, 收藏,
该文被密码保护。 阅读全文

java把彩色图片变成黑白图片

2014-01-15 10:24 by 默契., 2816 阅读, 0 推荐, 收藏,
摘要:package cn.moqi.test;import java.awt.image.BufferedImage;import java.io.File;import javax.imageio.ImageIO;public class Test { public static void main(String[] args) throws Exception { BufferedImage img = ImageIO.read(new File("d:/id_card.jpg")); final int width = img.getWidth(); ... 阅读全文

SAE中使用Django发送邮件遇到的几个问题

2014-01-10 09:58 by 默契., 488 阅读, 0 推荐, 收藏,
摘要:1,账号验证失败;SAE建议使用新浪邮箱,于是我马上去注册了一个,但是使用邮箱服务的时候一直提示验证失败;原因是新浪邮箱的smtp服务必须手动开启,在邮箱设置里面开启就可以了;2,链接超时:开启smtp服务后使用新浪自带的邮箱api发送成功,使用django提示连接超时,原因是新浪给的案例中sett... 阅读全文

Django的ORM中表名与表中的字段名设置;

2014-01-06 16:03 by 默契., 665 阅读, 0 推荐, 收藏,
摘要:表名设置:在模型类的Meta设置db_table="表名"如:class Posts(models): posts_id=models.AutoField(primary_key=True); class Meta: db_table="t_posts"更多Meta属性请参照:https://docs.djangoproject.com/en/dev/ref/models/options/字段名称设置:在字段类型定义时设置参数db_column=字段名;如:class Posts(models): posts_id=models.AutoField(pr 阅读全文

Android获取基站信息

2013-12-31 16:31 by 默契., 1327 阅读, 0 推荐, 收藏,
摘要:package cn.police.bz.util;import android.content.Context;import android.telephony.CellLocation;import android.telephony.TelephonyManager;import android.telephony.cdma.CdmaCellLocation;import android.telephony.gsm.GsmCellLocation;public class BaseStationInfoHelper { public static class BaseStation... 阅读全文

Android获取签名相同的软件列表(签名比对)

2013-12-30 16:10 by 默契., 442 阅读, 0 推荐, 收藏,
摘要:try { PackageManager pmg = getPackageManager(); List apps = pmg.getInstalledApplications(0); Signature ss1 = pmg.getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES).signatures[0]; for (int i = 0; i < apps.size(); i++) { S... 阅读全文

HttpClient两个超时设置的区别

2013-12-19 14:53 by 默契., 402 阅读, 0 推荐, 收藏,
摘要:HttpClient关于超时有两个设置,一个是CONNECTION_TIMEOUT还有一个是SO_TIMEOUT;CONNECTION_TIMEOUT是指的是,从发出TCP请求,到建立起连接的时间,一般比较小,如:5*1000SO_TIMEOUT是指从建立起连接到结束的时间,一般比较大,如:30*1000;这两个值默认好像都是无限大,在使用中务必进行设置,否则可能造成软件卡死,当多个线程使用同一个HttpClient的时候,如果一个线程没有执行完成,另外一个线程也是无法执行的; 阅读全文

HttpClient的文件上传进度

2013-12-19 10:03 by 默契., 1418 阅读, 0 推荐, 收藏,
摘要:package cn.police.bz.util;import java.io.File;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import org.apache.http.entity.mime.content.FileBody;import android.util.Log;/** * 能够显示进度的FileBody * * @author Mr_wu */public class FileBodySomeProgress extends FileBody { . 阅读全文

Animation中缩放View,中断动画后在低版本手机上背景无法还原的问题;

2013-11-28 10:01 by 默契., 430 阅读, 0 推荐, 收藏,
摘要:Animation代码如下import android.view.animation.Animation;import android.view.animation.Transformation;public class MetroAnimation extends Animation { private int width; private int height; public MetroAnimation(int width, int height) { this.width = width / 2; this.height = height ... 阅读全文

Android让Diglog中的元素fill_parent属性生效

2013-11-18 09:02 by 默契., 263 阅读, 0 推荐, 收藏,
摘要:lodingDialog = new Dialog(this,R.style.dialog_noBorder); lodingDialog.setContentView(R.layout.file_explore_dialog_loading); //让ContentView的fill_parent属性生效 lodingDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 阅读全文