0
我開發一個機器人應用,其中我使用的GIF圖像用下面的代碼在表面視圖中使用Gif圖像?
private static byte[] streamToBytes(InputStream is) {
ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
byte[] buffer = new byte[1024];
int len;
try {
while ((len = is.read(buffer)) >= 0) {
os.write(buffer, 0, len);
}
} catch (java.io.IOException e) {
}
return os.toByteArray();
}
//在通過從樣活性ontouch我出口類
is = this.context.getResources().openRawResource(R.drawable.fondo_juego_nexus);
if (DECODE_STREAM) {
System.out.println("in if DECODE_STREAM");
mMovie = Movie.decodeStream(is);
}
else {
byte[] array = streamToBytes(is);
System.out.println("in else DECODE_STREAM");
mMovie = Movie.decodeByteArray(array, 0, array.length);
}
// In On Draw
long now = android.os.SystemClock.uptimeMillis();
if (mMovieStart == 0) { // first time
mMovieStart = now;
}
if (mMovie != null) {
System.out.println("in if (mMovie != null) " + mMovie.duration());
int dur = mMovie.duration();
if (dur == 0)
{
dur = 1000;
System.out.println("in if movie if");
}
System.out.println("duration is "+ dur);
int relTime = (int)((now - mMovieStart) % dur);
mMovie.setTime(relTime);
System.out.println("in if displaying syd");
mMovie.draw(canvas,120,100);
}
的構造和
else if(_y<=60 && _x<=60)
{
sp.play(mySound1, volume, volume, 0, 0, 1);
sp.release();
playr.stop();
tme.cancel();
act.finish();
}
卜當我用上面的方法退出活動並返回到以前的活動, 又一次來到活動WH我使用gif圖像它不出現,在設備星系s2,2.3.3,但在一個相同的大小爲2.2的模擬器是好的
是否有任何問題,這種方法或我可以用什麼方式來顯示GIF圖像
我應該怎麼做才能消除這種錯誤