0

This is the code for the first screen and I have used all import statements for both the screens. I have a conditional statement which check if the editText Boxes or the ratingBar is empty or not.

public class BasicDetails extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.basic_details_screen);

        TextView textClass = (TextView)findViewById(R.id.textClass);
        TextView textSchool = (TextView)findViewById(R.id.textSchool);
        TextView textPhoto = (TextView)findViewById(R.id.textPhoto);
        TextView textabtYear = (TextView)findViewById(R.id.textabtYear);

        final EditText editClass = (EditText)findViewById(R.id.editClass);
        final EditText editSchool = (EditText)findViewById(R.id.editSchool);
        final EditText abtyear = (EditText)findViewById(R.id.abtYear);

        //Button buttonPhoto = (Button)findViewById(R.id.buttonPhoto);
        Button buttonBnext = (Button)findViewById(R.id.buttonBnext);

        buttonBnext.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Performs action on click
                if ((editClass.getText().length() != 0) && (editSchool.getText().length() != 0) && (abtyear.getText().length() != 0)) {
                    Intent intent = new Intent(BasicDetails.this, PortfolioDetails.class);
                    startActivity(intent);
                    //opens the portfolio details class

                } else {
                    Toast.makeText(BasicDetails.this, "Please enter all the details!!!", Toast.LENGTH_LONG).show();
                }
            }
        });

    }
}

And this is the code for the next screen. So basically there is an intent which takes you from one screen to the other but I get a error message on my emulator that"My app(or GoPort)has unfortunately stopped working"

public class PortfolioDetails extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.porfolio_details_screen);

        TextView textAchievements = (TextView)findViewById(R.id.textAchievements);
        TextView textProgress = (TextView)findViewById(R.id.textProgress);
        TextView textFeedback = (TextView)findViewById(R.id.textFeedback);

        final EditText editAchievements = (EditText)findViewById(R.id.editAchievements);
        final EditText editFeedback = (EditText)findViewById(R.id.editFeedback);

        final RatingBar ratingBar = (RatingBar)findViewById(R.id.ratingBar);

        Button buttonCnext = (Button)findViewById(R.id.buttonCNext);

        buttonCnext.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Performs action on click

                if ((editAchievements.getText().length() != 0) && (editFeedback.getText().length() != 0)) {

                    ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
                        public void onRatingChanged(RatingBar ratingBar, float rating,
                                                    boolean fromUser) {
                            // place intent for new activity

                            Intent intent = new Intent(PortfolioDetails.this, SlamDetails.class);
                            startActivity(intent);
                            //opens the portfolio details class

                        }
                    });
                } else { 
                    Toast.makeText(PortfolioDetails.this, "Please enter all the details!!!", Toast.LENGTH_LONG).show();
                }
            }
        });

    }
}

I get this in my log: The red text is what I feel is an error

Prateek Mahesh
  • 455
  • 1
  • 5
  • 10
  • 2
    can you attach the error log you see in logcat – Godslave Jul 17 '16 at 05:20
  • 1
    Read: http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – Morrison Chang Jul 17 '16 at 05:37
  • can you define what is your problem ?? – Harshad Pansuriya Jul 17 '16 at 05:49
  • @Ironman basically what happens is that I have a home screen.class where you enter your name and then click on a button to start. Once you click on that button, You go to the BasicDetails.class and when I input all the required details there, I click on the next button to go to the PortfolioDetails.class and thats when I encounter an error which says "GoPort has unfortunately stopped working" – Prateek Mahesh Jul 17 '16 at 06:27
  • @GodslaveAsad I don't have any errors as such in the logcat but the apps stops working thats what I am trying to resolve. But I do see some text red in log but it doesn't seem to look like an error – Prateek Mahesh Jul 17 '16 at 06:30
  • It is showing error at **BasicDetails.java:43**. Which line is written on line 43 ? Also its showing ActivityNotFoundException, so make sure the activity is registered in AndroidManifest. – Somendra Meena Jul 17 '16 at 06:41
  • @Somendra Meena ok so how do I do it..I am using a macbook (just for your info) – Prateek Mahesh Jul 17 '16 at 06:48
  • on line 43 I have startActivity(intent) is the error because I have duplicate variable (intent)in all the screens??? – Prateek Mahesh Jul 17 '16 at 06:50
  • thank you @SomendraMeena I have done it!! – Prateek Mahesh Jul 17 '16 at 06:55
  • Go to your `app` folder and then in `manifests` open `AndroidManifest.xml` and then add activity within your `application` tag. Add your activity like this : ... – Somendra Meena Jul 17 '16 at 06:55
  • Having duplicate _variable_ will not cause any problem if they are on different activities. If you have same variable name within a activity and if one is having scope in another part (where sec. variable is used), then it will give error. Otherwise you won't get any error cause of that. – Somendra Meena Jul 17 '16 at 06:58

1 Answers1

-1

I actually forgot to add the activity to the intent

Yeah I solved the issue....Basically there was no problem with the intent

Prateek Mahesh
  • 455
  • 1
  • 5
  • 10
  • also add `SlamDetails` in your Manifest file because you are using it in your `PortfolioDetails` Activity. Otherwise you will again go in that situation. – Somendra Meena Jul 17 '16 at 07:00