kgsharathkumar kgsharathkumar - 14 days ago 8
Android Question

startActivities(android.content.Intent[]) in Activity cannot be Applied to (android.content.Intent)

I try to do one simple application, in that Intent Not working, it shows this error:


startActivities(android.content.Intent[]) in Activity cannot be Applied to (android.content.Intent)


Why?

See below my code:

public class SplashActivity extends Activity implements Animation.AnimationListener {
ImageView imageView;
Button button;
Animation animationbounce;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
imageView = (ImageView)findViewById(R.id.face);
button = (Button)findViewById(R.id.splash);
animationbounce = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bounce);
animationbounce.setAnimationListener(this);
imageView.setVisibility(View.VISIBLE);
imageView.startAnimation(animationbounce);
animationbounce.setRepeatMode(Animation.REVERSE);

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageView.setVisibility(View.VISIBLE);
imageView.startAnimation(animationbounce);
}
});

Thread timerThread = new Thread() {

public void run() {

try {
sleep(1000);


} catch (InterruptedException e) {
e.printStackTrace();
} finally {

Intent intents = new Intent(SplashActivity.this, MainActivity.class);
SplashActivity.this.startActivities(intents);
// startActivities(intents);

}
}
};
timerThread.start();
}

@Override
public void onAnimationStart(Animation animation) {
imageView.setVisibility(View.VISIBLE);
imageView.startAnimation(animationbounce);
}

@Override
public void onAnimationEnd(Animation animation) {
if(animation==animationbounce)
{
imageView.setVisibility(View.VISIBLE);
imageView.startAnimation(animationbounce);
}

}

@Override
public void onAnimationRepeat(Animation animation) {

imageView.setVisibility(View.VISIBLE);
imageView.startAnimation(animationbounce);
}
}

Answer

startActivities expect an array of Intents (Intent[]) to be provided. You try to pass a single Intent there. Use startActivity(Intent) instead.

Comments