skip to Main Content

Red Lines under the package when intenting
Here I tried to copy the name of the package in the class part but apparently it isn’t working please help

2

Answers


  1. as a second param for intent you should pass desired Activitys class, not package name

    e.g. if you would want to open new instance of MainActivity:

    new Intent(MainActivity.this, com.example.goaltracker.MainActivity.class);
    

    in fact com.example.goaltracker. prefix isn’t needed, you may just import desired Activity class (new Intent(MainActivity.this, DesiredActivity.class))

    PS. NEVER post code/text as screenshot!!!

    Login or Signup to reply.
  2. Instead of this:

    Intent intent = new Intent(MainActivity.this, com.example.goaltracker.Class);
    

    Use this :

    Intent intent = new Intent(MainActivity.this, goaltracker.Class);
    

    And when you create an activity, the preference is to name the first caractere of the word in uppercase, for example : GoalTracker.class

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search