Search code examples
javaandroidandroid-studiooncreate

can't open the page, android studio


I'm programming an individual app. I've got an strange problem. Yesterday the app was ok and today when i want to go to another page the app stoped. It is only one page which stoped.

this is a piece of my code from this page:

@Override
 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lebensmittel_start_seite);

    infoText = (TextView) findViewById(R.id.leb_info_text);
    infoText.setText("Die Kohlenhydratmenge bei abgepackten Lebensmitteln und " +
            "Fertigprodukten finden Sie bei den Nährwertangaben. Die KE können " +
            "Sie berechnen, indem Sie die Kohlenhydratmenge pro 100 g durch 10 teilen." +
            "Beispiel: 100 g Schokolade = 48 g Kohlenhydrate 48 g / 10 = 4,8 KE");

    spinner1=(Spinner) findViewById(R.id.spinner);
    spinner2=(Spinner) findViewById(R.id.spinner_leb);
    ArrayAdapter adapter1= createFromResource(this, R.array.menue_array, android.R.layout.simple_spinner_item);
    ArrayAdapter adapter2= createFromResource(this, R.array.Lebensmittel_Liste, android.R.layout.simple_spinner_dropdown_item);
    spinner1.setAdapter(adapter1);
    spinner2.setAdapter(adapter2);
    spinner1.setOnItemSelectedListener(this);
    spinner2.setOnItemSelectedListener(this);
}

this is my logcat:

09-20 09:39:02.237 2592-2592/com.example.mac.diabetikerhilfe E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.mac.diabetikerhilfe, PID: 2592
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.mac.diabetikerhilfe/com.example.mac.diabetikerhilfe.LebensmittelSeiten.Lebensmittel_Start_Seite}; have you declared this activity in your AndroidManifest.xml?
   at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1932)
   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1615)
   at android.app.Activity.startActivityForResult(Activity.java:4472)
   at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:54)
   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
   at android.app.Activity.startActivityForResult(Activity.java:4430)
   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:708)
   at android.app.Activity.startActivity(Activity.java:4791)
   at android.app.Activity.startActivity(Activity.java:4759)
   at com.example.mac.diabetikerhilfe.Start.onItemSelected(Start.java:60)
   at android.widget.AdapterView.fireOnSelected(AdapterView.java:944)
   at android.widget.AdapterView.dispatchOnItemSelected(AdapterView.java:933)
   at android.widget.AdapterView.-wrap1(Unknown Source:0)
   at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:898)
   at android.os.Handler.handleCallback(Handler.java:789)
   at android.os.Handler.dispatchMessage(Handler.java:98)
   at android.os.Looper.loop(Looper.java:164)
   at android.app.ActivityThread.main(ActivityThread.java:6541)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Solution

  • android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.mac.diabetikerhilfe/com.example.mac.diabetikerhilfe.LebensmittelSeiten.Lebensmittel_Start_Seite}; AndroidManifest.xml?

    Declared Your Activity on AndroidManifest.xml

       <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
       <activity android:name=".ActivityName"/>
    
       </applications>