ITeye博客

lmx227的博客

lmx227 · 共 25 篇文章

Http Post上传图片

String filepath = "/storage/sdcard0/ShareSDK/cn.sharesdk.demo/cache/pic_glance_back.jpg"; /** * 上传图片 * * @param urlStr 上传服务器地址 * @param textMap * @param fileMap * @return */ public String formUpload(String urlStr, Map<String, String> textMap, Map<String, String> fileMap) { String res = ""; HttpURLC…

2014-08-05 16:54 · 评论(0)

Http Post请求

/** * 创建相册请求 * 参数: * name:相册名 * description:相册描述 * tags:标签 * uid:uid */ private void createAlbum() { HashMap<String, String> params = new HashMap<String, String>(); params.put("uid", String.valueOf(1102130)); params.put("name", "my_album2"); params.put("description", "this is description2"); params…

2014-08-04 16:10 · 评论(0)

Android 监听wifi, 3g的开、关

private BroadcastReceiver mConnReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean isWifiConnected = false; boolean isMobileConnected = false; ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY…

2014-06-24 15:46 · 评论(0)

TelephonyManager

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/phone_type" android:layout_width="fill_parent" android:l…

2014-06-24 15:44 · 评论(0)

MD5 加密

public static String md5(String password) { MessageDigest md; try { // 生成一个MD5加密计算摘要 md = MessageDigest.getInstance("MD5"); // 计算md5函数 md.update(password.getBytes()); // digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符 // BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值 String …

2014-06-20 11:04 · 评论(0)

获取IP地址

/** * 用来获取手机拨号上网(包括CTWAP和CTNET)时由PDSN分配给手机终端的源IP地址。 * * @return ipv4 */ private String getLocalIp() { try { for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr =…

2014-06-20 11:02 · 评论(0)

判断一个数是否是完全平方数

利用恒等式: 1+3+5+7+....+(2*n-1)=n^2 bool isSqrt(int n) { for(int i=1;n>0;i+=2) n-=i; return 0 == n; } 下面是一些关于完全平方数的数学性质: 对排除完全平方数有一定的加速作用: 性质1:完全平方数的末位数只能是0,1,4,5,6,9。 性质2:奇数的平方的个位数字为奇数,十位数字为偶数。 证明 奇数必为下列五种形式之一: 10a+1, 10a+3, 10a+5, 10a+7, 10a+9 分别平方后,得 (10a+1)^2=100+20a+1=20a(5a+1)+1 (10a+3)^2=100+60a…

2013-05-23 14:44 · 评论(0)

JAVA经典的50道题

【程序1】 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? 1.程序分析: 兔子的规律为数列1,1,2,3,5,8,13,21.... 【程序2】 题目:判断101-200之间有多少个素数,并输出所有素数。 1.程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除, 则表明此数不是素数,反之是素数。 【程序3】 题目:打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个 "水仙花数 ",因为153=1的三…

2013-05-22 14:49 · 评论(0)

写Xml文件

import java.io.FileWriter; import java.io.IOException; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.dom4j.io.OutputFormat; import org.dom4j.io.XMLWriter; public class CreateXML { public static Document getDocument(){ Document document = DocumentHe…

2011-05-25 15:03 · 评论(0)

Debug certificate expired on DATE 解决方法

Once in a while the SDK shows some hickups – usually easy to solve. As this one. Today i got this error message “Error generating final archive: Debug certificate expired on …” while building an apk file inside Eclipse to be run in the emulator on a machine which has not been used for a while. If y…

2011-05-24 01:01 · 评论(0)

获得 ScrollView 惯性滑动后的位置

public class ScrollOnTouchListener implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: scrollX = horizontalScrollVi…

2011-04-18 23:55 · 评论(0)

代码开启关闭Gps

在Android 2.2以后才可使用 /** * Gets the state of GPS location. * * @param context * @return true if enabled. */ private static boolean getGpsState(Context context) { ContentResolver resolver = context.getContentResolver(); boolean open = Settings.Secure.isLocationProviderEnabled(resolver, LocationManager…

2011-02-28 22:31 · 评论(9)

Android SMS PDU

7-bit编码:发送普通ASCII字符; 8-bit编码:通常用于发送数据消息; UCS2编码:用于发送Unicode字符。 而一般的PDU编码由A B C D E F G H I J K L M十三项组成,其中这十三项的释义分别为: A:短信息中心地址长度,2位十六进制数(1字节)。 B:短信息中心号码类型,2位十六进制数。 C:短信息中心号码,B+C的长度将由A中的数据决定。 D:文件头字节,2位十六进制数。 E:信息类型,2位十六进制数。 F:被叫号码长度,2位十六进制数。 G:被叫号码类型,2位十六进制数,取值同B。 H:被叫号码,长度由F中的数据决定。 I:协议标识,2位十六进制数…

2011-02-17 22:03 · 评论(0)

MMS PDU

手机接收短信后,Android(Android 2.2.1 From CyanogenMod For G6)在LogCat中会这样一个输出: 12-17 16:24:16.425: DEBUG/WAP PUSH(230): Rx: ae06246170706c69636174696f6e2f766e642e7761702e6d6d732d6d65737361676500b487af84[data:8c82985251594278686467766b2b41008d9083687474703a2f2f3231312e3133362e3232312e37352f52515942786864677…

2011-02-17 21:52 · 评论(0)

Eclipse配置NDK_R4开发环境(集成Cygwin 、CDT)

前确认Cygwin已经安装成功, 并在Cygwin 运行环境里配置了NDK 的路径(如F:\android\NDK\android-ndk-r4)到 PATH 环境变量里。 1. 为NDK工程添加Builder 选择 相应的 Project ,点击右键 选择 Properties ,在窗口里选择Builders , 新增一个“Android NDK Builder”编译配置: 2. 配置 2.1 在Main 页面里 Location 栏 选择 你安装Cygewin时配置的root目录下的 bash.exe 所在路径, F:\android\NDK\Cygewin\root\bin\bash.…

2010-12-21 23:36 · 评论(0)