Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Android Acrivity and delays

AnuraagAnuraag IndiaMember Posts: 1
edited March 2015 in Android

I have two activities AppexActivity and QuestionActivity. I want to first start AppexActivity and then start QuestionActivity after 5 seconds automatically. This is the code I have written:

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(getActivity(), AppexActivity.class);
                startActivity(intent);
                getActivity().finish();
            }
        },5000);
    final View rootView = inflater.inflate(R.layout.activity_main, container, false);
    Button StartButton = (Button) rootView.findViewById(R.id.startbutton);
        Typeface typeface=Typeface.createFromAsset(getActivity().getAssets(),"fonts/1942.ttf");
        StartButton.setTypeface(typeface);
    StartButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), QuestionActivity.class);
                startActivity(intent);
        }
    });
    return rootView;
}

When this run QuestionActivity runs for 5 seconds instead of AppexActivity. What am I doing wrong?
Tagged:
Sign In or Register to comment.