Home > Mobile >  Is there a way i can fix this ? i tried to copy the name of the package in the intent but it isn
Is there a way i can fix this ? i tried to copy the name of the package in the intent but it isn

Time:09-10

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

CodePudding user response:

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!!!

CodePudding user response:

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

  • Related