vendredi 8 juillet 2016

Next activity with intent is closing immediately

I have some issues with next activity - I made a button, and when you click on it, an intent is being made, and then you "startActivity" with the intent. I declared the source and the destination classes. Everytime I click the button, it closes the app and says "Unfortunately, My First Application has stopped." Any help? Thanks in advance.

package com.myfirstapplication.owner.myfirstapplication;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

Button nextAc;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    nextAc = (Button) findViewById(R.id.nextPageButton);

    nextAc.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(MainActivity.this, SecondActivity.class);

            Bundle fromMain = new Bundle();
            fromMain.putString("BundleInfo","Look at that.");

            i.putExtras(fromMain);
            startActivity(i);

        }
    });

}

}

Aucun commentaire:

Enregistrer un commentaire