Hello! I try to start activating in a separate thread with a period of time, the code is this: And the question itself: everything works, the activity starts, whether it is possible to make a separate method or how, so that you don’t write new Handler().postDelayed(new Runnable() { in each case new Handler().postDelayed(new Runnable() {
arr_imageA[i].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { v.startAnimation(anim); mediaPlayer.start(); playSample(R.raw.click_sound); switch (v.getId()) { case R.id.imageView1: new Handler().postDelayed(new Runnable() { @Override public void run() { startActivity(new Intent(getActivity(), a1.class)); } }, 100); break; case R.id.imageView2://todo копипаст startActivity(new Intent(getActivity(), a2.class)); break; case R.id.imageView3: startActivity(new Intent(getActivity(), a3.class)); break; } } });