在使用Toast时报异常:java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare();
请在stackoverflow.com这个问题下看Eric Leschinski的回答。
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare();
基本解决方法就是在主线程使用Toast。Android jni 报错:"make:******没有规则可以创建******.o”需要的目标“****.cpp”。 停止。"
出现这个这个错误,可能是因为android.mk的文件格式可能是windows下拷贝,或是从网页copy,只要把Android.mk文件行尾一些多余的看不见字符清除即可。java short数组和byte数组互转
public static byte[] toByteArray(short[] src) {
int count = src.length;
byte[] dest = new byte[count << 1];
for (int i = 0; i < count; i++) {
dest[i * 2] = (byte) (src[i]);
dest[i * 2 + 1] = (byte) (src[i] >> 8);
}
return dest;
}
public short[] toShortArray(byte[] src) {
int count = src.length >> 1;
short[] dest = new short[count];
for (int i = 0; i < count; i++) {
dest[i] = (short) ((src[i * 2] & 0xff) | ((src[2 * i + 1] & 0xff) << 8));
}
return dest;
}
Android 添加support library(针对Eclipse)
在Eclipse添加Android兼容包( v4、v7 appcompat )