Utkarsh
Utkarsh

Reputation: 3

App crashing when starts an activity with intent

The app crashes in Android Studio when a button is clicked to reach the another activity through intent

public void next(View view) {
    Toast.makeText(getApplicationContext()," Next called " , Toast.LENGTH_SHORT).show();  
    startActivity(new Intent(getApplicationContext(),SecondActivity.class));     
}

The error I am getting from logcat is

Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.utkarsh.internalstorage/com.example.utkarsh.internalstorage.SecondActivity}; have you declared this activity in your AndroidManifest.xml?

Upvotes: 0

Views: 119

Answers (3)

emilpmp
emilpmp

Reputation: 1736

specify activity in your android manifest file <activity android:name="SecondActivity"> </activity>

Upvotes: 1

Nizam
Nizam

Reputation: 5731

The issue is, the SecondActivity Activity wasn't added to the AndroidManifest.xml. Once you add that as an application node, it will work properly.

<activity android:name="com.example.utkarsh.internalstorage.SecondActivity" />

Upvotes: 0

FarshidABZ
FarshidABZ

Reputation: 4123

Error message is clear, define your activity in your manifest

Upvotes: 0

Related Questions