将字符串进行MD5加密,返回加密后的字符串(实际上是该字符串的报文摘要)。
byte[] hash;
try {
hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Huh, MD5 should be supported?", e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Huh, UTF-8 should be supported?", e);
}
StringBuilder hex = new StringBuilder(hash.length * 2);
for (byte b : hash) {
if ((b & 0xFF) < 0x10) hex.append("0");
hex.append(Integer.toHexString(b & 0xFF));
}
return hex.toString();
}
博客:http://bobli.cnblogs.com/
日期:2012年3月26日
原理是遍历所有网络接口的所有IP地址。如果方法返回null,则设备没有可用的网络连接。方法返回的IP地址是设备正在使用的IP地址。
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
Log.e(LOG_TAG, ex.toString());
}
return null;
}
参考:http://www.droidnova.com/get-the-ip-address-of-your-device,304.html
博客:http://bobli.cnblogs.com/
日期:2012年3月26日
iOS
使用 NSObject 基类的 isKindOfClass: 方法。
声明:
- (BOOL)isKindOfClass:(Class)aClass
描述:
Returns a Boolean value that indicates whether the receiver is an instance of given class or an instance of any class that inherits from that class. (required)
参数:
aClass: A class object representing the Objective-C class to be tested.
返回值:
YES if the receiver is an instance of aClass or an instance of any class that inherits from aClass, otherwise NO.
示例代码:
if ([ctrl isKindOfClass:[UITextField class]]) {
[(UITextField*)ctrl setText:@""];
}
else if ([ctrl isKindOfClass:[UISwitch class]]) {
[(UISwitch*)ctrl setOn:NO];
}
}
Android
The instanceof operator compares an object to a specified type. You can use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface.
示例代码:
{
if(v instanceof TextView)
{
// This is a TextView control
} else {
// This is not a TextView control
}
}
Windows Phone
C# 的 is 操作符关键字。Checks if an object is compatible with a given type. An is expression evaluates to true if the provided expression is non-null, and the provided object can be cast to the provided type without causing an exception to be thrown.
示例代码:
if (ctrl is TextBlock) {
//TextBlock
}
else if (ctrl is TextBox) {
//TextBox
}
}
作者:黎波
博客:http://bobli.cnblogs.com/
日期:2012年3月14日
精至手机药典iPhone版已经完成了第二版的开发和测试,正在等待AppStore的审批。已越狱的iPhone很快就能下载使用了。第二版加入了历史前进和后退导航,从历史打开页面,以及收藏和注释功能,大大提升了用户体验!
启动界面

主界面

药品目录


药品

药品相互作用


药物类别

药品搜索

相互作用搜索

用药指南


临床计算工具

诊断评估工具

收藏

历史

选项

使用帮助

官方博客:http://blog.sina.com.cn/jzhmed
App Store:http://itunes.apple.com/cn/app/id490834552
作者:黎波
博客:http://bobli.cnblogs.com/
日期:2012年1月15日(2.0),2011年12月20日(1.0)
1.判断字符串是否为空
// empty string
}
2.字符串连接
NSString *str2 = @"str2";
NSString *result;
//方法1
result = [str1 stringByAppendingString:str2];
NSLog(result, nil);
//方法2
result = [NSString stringWithFormat:@"%@%@", str1, str2];
NSLog(result, nil);
//方法3
result = [@"" stringByAppendingFormat:@"%@%@", str1, str2];
NSLog(result, nil);
//方法4
NSMutableString *ms = [[NSMutableString alloc] init];
[ms appendString:str1];
[ms appendString:str2];
NSLog(ms, nil);
[ms release];
//结果都是:str1str2
一般推荐使用方法1,如果需要大量字符串连接推荐使用方法4,需要更少的内存开销。
3.去除字符串首尾的空格和换行符
4.多行书写字符串常量
"FROM [Customer] "
"WHERE [CustomerID] = 1234";
NSString *str2 = @"SELECT [CustomerID], [CustomerName] \
FROM [Customer] \
WHERE [CustomerID] = 1234";
NSLog(str1, nil);
NSLog(str2, nil);
//结果都是:SELECT [CustomerID], [CustomerName] FROM [Customer] WHERE [CustomerID] = 1234
注意字符串中每行结尾处的空格。这种字符串声明方式虽然看上去是多行,实际上字符串中并没有换行符,也就是说整个字符串实际上是一行。如果需要在字符串中换行,可以在字符串中加入换行符"\n"。这种声明方式一般用在需要在代码中多行显示字符串以便提高可读性,例如:SQL语句往往需要多行显示来提高可读性、较长的文本的段落之间需要分行显示以便更容易找到分段位置。
此文将不断更新...
作者:黎波
博客:http://bobli.cnblogs.com/
日期:2011年12月7日
这是最近完成的一个iPhone app。《目标身高》根据各省的调查数据和身高遗传特点进行计算,来算算你家宝贝能长多高吧。


App Store
http://itunes.apple.com/cn/app/id478325161
作者:黎波
博客:http://bobli.cnblogs.com/
日期:2011年12月2日
这是最近完成的一个Android App。目标身高根据各省的调查数据和身高遗传特点进行计算,来算算你家宝贝能长多高吧。

Android Market Page
https://play.google.com/store/apps/details?id=com.jingzhimed.targetheight
作者:黎波
博客:http://bobli.cnblogs.com/
日期:2011年12月2日