Buongiorno a tutti,
ho creato un timer dove mi carica delle immagini da un array, ora dopo essere arrivata all'ultima immagine mi dovrebbe richiamare un activity chiamata menu, l'app raggiunta la centesima immagini si chiede dando errore e mi si riapre con l'activity correttamente caricata
sicuramente c'è qualcosa che sbaglio ma il codice mi sembra corretto.
package com.gendiripal.devildragon.dragonstorm;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
/**
* Created by DevilDragon on 11/03/2017.
*/
public class caricamento extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.caricamento);
// setting image resource from drawable
final int []imageArray={R.drawable.termometro000,R.drawable.termometro001,R.drawable.termometro002,R.drawable.termometro003,R.drawable.termometro004,R.drawable.termometro005,R.drawable.termometro006,R.drawable.termometro007,R.drawable.termometro008,R.drawable.termometro009,R.drawable.termometro010,R.drawable.termometro011,R.drawable.termometro012,R.drawable.termometro013,R.drawable.termometro014,R.drawable.termometro015,R.drawable.termometro016,R.drawable.termometro017,R.drawable.termometro018,R.drawable.termometro019,R.drawable.termometro020,R.drawable.termometro021,R.drawable.termometro022,R.drawable.termometro023,R.drawable.termometro024,R.drawable.termometro025,R.drawable.termometro026,R.drawable.termometro027,R.drawable.termometro028,R.drawable.termometro029,R.drawable.termometro030,R.drawable.termometro031,R.drawable.termometro032,R.drawable.termometro033,R.drawable.termometro034,R.drawable.termometro035,R.drawable.termometro036,R.drawable.termometro037,R.drawable.termometro038,R.drawable.termometro039,R.drawable.termometro040,R.drawable.termometro041,R.drawable.termometro042,R.drawable.termometro043,R.drawable.termometro044,R.drawable.termometro045,R.drawable.termometro046,R.drawable.termometro047,R.drawable.termometro048,R.drawable.termometro049,R.drawable.termometro050,R.drawable.termometro051,R.drawable.termometro052,R.drawable.termometro053,R.drawable.termometro054,R.drawable.termometro055,R.drawable.termometro056,R.drawable.termometro057,R.drawable.termometro058,R.drawable.termometro059,R.drawable.termometro060,R.drawable.termometro061,R.drawable.termometro062,R.drawable.termometro063,R.drawable.termometro064,R.drawable.termometro065,R.drawable.termometro066,R.drawable.termometro067,R.drawable.termometro068,R.drawable.termometro069,R.drawable.termometro070,R.drawable.termometro071,R.drawable.termometro072,R.drawable.termometro073,R.drawable.termometro074,R.drawable.termometro075,R.drawable.termometro076,R.drawable.termometro077,R.drawable.termometro078,R.drawable.termometro079,R.drawable.termometro080,R.drawable.termometro081,R.drawable.termometro082,R.drawable.termometro083,R.drawable.termometro084,R.drawable.termometro085,R.drawable.termometro086,R.drawable.termometro087,R.drawable.termometro088,R.drawable.termometro089,R.drawable.termometro090,R.drawable.termometro091,R.drawable.termometro092,R.drawable.termometro093,R.drawable.termometro094,R.drawable.termometro095,R.drawable.termometro096,R.drawable.termometro097,R.drawable.termometro098,R.drawable.termometro099,R.drawable.termometro100};
final Handler handler = new Handler();
Runnable runnable = new Runnable() {
int i=0;
ImageView imageView = (ImageView) findViewById(R.id.imageView);
@Override
public void run() {
imageView.setImageResource(imageArray[i]);
i++;
if(i>imageArray.length-1)
{
Intent a = new Intent(caricamento.this, menu.class);
startActivity(a);
finish();
}
handler.postDelayed(this,20);
}
};
handler.postDelayed(runnable,50);
}
}
sapreste dirmi dove sbaglio?
grazie ancora