user3764379
user3764379

Reputation: 27

Crash when launching a new Activity from a Fragment

I get an error when launching an activity from a fragment, using an intent.

Intent intent = new Intent(this.getActivity(),FormActivity.class);

intent.putExtra("Horas",hours);
intent.putExtra("Minutos",minutes);
intent.putExtra("Segundos",seconds);
intent.putExtra("Fecha",date);
intent.putExtra("Hora",time);

startActivity(intent);

LogCat:

android.content.ActivityNotFoundException: Unable to find explicit activity class
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1719)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1491)
at android.app.Activity.startActivityForResult(Activity.java:3436)
at android.app.Activity.startActivityForResult(Activity.java:3393)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:848)
at android.support.v4.app.Fragment.startActivity(Fragment.java:878)
at es.timetrack.app.InActivityPageFragment.onClick(InActivityPageFragment.java:148)

Upvotes: 1

Views: 1321

Answers (1)

Philipp Jahoda
Philipp Jahoda

Reputation: 51411

Declare the Activity you are starting in the Manifest .xml file:

<activity
      android:name="your.package.FormActivity"
      android:label="FormActivity" />

Some additional information: The App Manifest

There you can see the structure of the manifest.xml file and what it is used for.

In addition to you not declaring your Activity in the manifest file, your application might crash due to unhandled exceptions in the onCreate(...) method of your FormActivity.

Upvotes: 3

Related Questions