Criminal Intent is Crashing on startActivity(intent)


#1

When I am typing this code

private class CrimeHolder extends RecyclerView.ViewHolder
implements View.OnClickListener {

@Override
public void onClick(View view) {
Toast.makeText(getActivity(),
mCrime.getTitle() + " clicked!", Toast.LENGTH_SHORT)
.show();
Intent intent = new Intent(getActivity(), CrimeActivity.class);
startActivity(intent);
}
}

My App crashes when I click any of the crime in my recycler view. I am unable to figure it out. Please guide me.


#2

I figured it out. The problem is

Before starting the activity, the ActivityManager checks the package’s manifest for a declaration with the same name as the specified Class. If it finds a declaration, it starts the activity, and all is well. If it
does not, you get a nasty ActivityNotFoundException, which will crash your app. This is why all of
your activities must be declared in the manifest.

So just add this in your manifest.xml