在使用Toast時(shí)報(bào)異常:java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare();
請(qǐng)?jiān)趕tackoverflow.com這個(gè)問(wèn)題下看Eric Leschinski的回答捷兰。
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare();
基本解決方法就是在主線程使用Toast惕鼓。Android jni 報(bào)錯(cuò):"make:******沒(méi)有規(guī)則可以創(chuàng)建******.o”需要的目標(biāo)“****.cpp”。 停止鳍悠。"
出現(xiàn)這個(gè)這個(gè)錯(cuò)誤,可能是因?yàn)閍ndroid.mk的文件格式可能是windows下拷貝谓松,或是從網(wǎng)頁(yè)copy焕妙,只要把Android.mk文件行尾一些多余的看不見(jiàn)字符清除即可。java short數(shù)組和byte數(shù)組互轉(zhuǎn)
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(針對(duì)Eclipse)
在Eclipse添加Android兼容包( v4沃斤、v7 appcompat )