杨子刚的博客


Android开发速查

2015-02-05

获取SD路径

Environment.getExternalStorageDirectory().getPath() + "/";

md5

使用codec

import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;

String md5Hex = new String(Hex.encodeHex(DigestUtils.md5(url.getBytes())));

超大图片的显示

BitmapRegionDecoder bitmapDecoder = BitmapRegionDecoder.newInstance(pngPath, true);
bitmapDecoder.decodeRegion(tile.rect, null);

在Support Library的ActionBar上显示按钮

官方文档

res/menu/main_activity_actions.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
    <!-- Search, should appear as action button -->
    <item android:id="@+id/action_search"
          android:icon="@drawable/ic_action_search"
          android:title="@string/action_search"
          yourapp:showAsAction="ifRoom"  />
    ...
</menu>

关键的是"yourapp"这一个,第二行定义了一个命名空间。

程序icon大小

xhdpi: 96x96; hdpi: 72x72; mdpi: 48x48; ldpi: 36x36

Android Sutdio启动时不检查Android sdk

#Android Studio.app/Contents/bin/idea.properties
disable.android.first.run=true

查看jar文件

JD-GUI

将dex反编译为jar

sudo port install dex2jar
dex2jar.sh /path/to/dex/file.dex

Android同一项目编译多个apk

Mastering "Product Flavors" On Android