Problems with startActivity error Channel is unrecoverably Broken and will be disposed!

Asked

Viewed 261 times

0

My application is closing unexpectedly while doing a button event in the top menu. When this happens nothing is appearing in the Logcat I’m following the pattern like this:

Within a activity I put the método onOptionsItemSelected next:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if(id == R.id.favoritar){
        if (!restaurante.isFavorito()) {
            // Adiciona aos favoritos
            adicionarAosFavoritos();
        } else {
            // Remove
            removerDosFavoritos();
        }
    }else{
        Intent comentariosActivity = new Intent(getContext(), Comentarios.class); //Aqui é onde ta ocorrendo o error.
        startActivity(comentariosActivity);
        //Toast.makeText(getActivity(), "testando",  Toast.LENGTH_SHORT).show();
    }

    return super.onOptionsItemSelected(item);
}

In my classe java ComentariosActivity I do so:

package com.fomedemais.FomeDemais;

import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import com.fomedemais.FomeDemais.entity.retornos.Comentarios;
import org.androidannotations.annotations.EActivity;

import java.util.ArrayList;

@EActivity(R.layout.activity_comentarios)
public class ComentariosActivity extends ActionBarActivity {

ArrayList<Comentarios> lstComentarios;

private Toolbar mToolbar;
private NavigationDrawerFragment mNavigationDrawerFragment;
public static final String BACKSTACK = "backstack";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    mToolbar.setTitle("");
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager()
            .findFragmentById(R.id.fragment_drawer);
    mNavigationDrawerFragment.setup(R.id.fragment_drawer,
            (DrawerLayout) findViewById(R.id.drawer), mToolbar);
 }
}

And in my activity I do so:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="4dp"
    android:paddingRight="4dp"
    android:paddingTop="4dp"
    android:paddingBottom="4dp"
    tools:context=".MainActivity"
    android:background="#ff6eb6ff"
    android:onClick="startSecondActivity">


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="DRAGÃO"
    android:id="@+id/textView"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:textSize="@dimen/abc_text_size_display_3_material"
    android:textColor="#ffffffff" />
</RelativeLayout>

If there is something I can do to check the error, initially I just want to make the screen appear.

This mistake was spit on the screen:

05-18 12:15:40.123 4374-16314/? E/Androidruntime: FATAL EXCEPTION: main Process: com.fomedemais.Fomedemais, PID: 4374 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.fomedemais.FomeDemais/com.fomedemais.FomeDemais.ComentariosActivity}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523) at android.app.Activity.startActivityForResult(Activity.java:4225) at android.app.Activity.startActivityForResult(Activity.java:4183) at android.support.v4.app.Fragmentactivity.startActivityForResult(Fragmentactivity.java:748) at android.app.Activity.startActivity(Activity.java:4522) at android.app.Activity.startActivity(Activity.java:4490) Fomedemais.Fomedemais.fragments.Fragmentcardapio.onOptionsItemSelected(Fragmentcardapio.java:269) at android.support.v4.app.Fragment.performOptionsItemSelected(Fragment.java:2070) at android.support.v4.app.Fragmentmanagerimpl.dispatchOptionsItemSelected(Fragmentmanager.java:2118) at android.support.v4.app.Fragmentcontroller.dispatchOptionsItemSelected(Fragmentcontroller.java:295) at android.support.v4.app.Fragmentactivity.onMenuItemSelected(Fragmentactivity.java:331) at android.support.v7.app.Appcompatactivity.onMenuItemSelected(Appcompatactivity.java:147) at android.support.v7.internal.view.WindowCallbackWrapper.onMenuItemSelected(Windowcallbackwrapper.java:100) at android.support.v7.internal.view.WindowCallbackWrapper.onMenuItemSelected(Windowcallbackwrapper.java:100) at android.support.v7.internal.app.Toolbaractionbar$2.onMenuItemClick(Toolbaractionbar.java:73) at android.support.v7.widget.Toolbar$1.onMenuItemClick(Toolbar.java:180) at android.support.v7.widget.Actionmenuview$Menubuildercallback.onMenuItemSelected(Actionmenuview.java:761) at android.support.v7.internal.view.menu.Menubuilder.dispatchMenuItemSelected(Menubuilder.java:811) at android.support.v7.internal.view.menu.Menuitemimpl.invoke(Menuitemimpl.java:153) at android.support.v7.internal.view.menu.Menubuilder.performItemAction(Menubuilder.java:958) at android.support.v7.internal.view.menu.Menubuilder.performItemAction(Menubuilder.java:948) at android.support.v7.widget.Actionmenuview.invokeItem(Actionmenuview.java:619) )

After the amendment of AndroidManifest being like this:

 <activity
      android:name="ComentariosActivity"
      android:label="@string/app_name"
      android:screenOrientation="portrait" />

another error occurred:

05-18 12:21:58.557 17118-17466/? E/androidruntime: FATAL EXCEPTION: main Process: com.fomedemais.Fomedemais, PID: 17118 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fomedemais.FomeDemais/com.fomedemais.FomeDemais.ComentariosActivity}: android.view.InflateException: Binary XML file line #28: Binary XML file line #28: Error inflating class fragment at android.app.Activitythread.performLaunchActivity(Activitythread.java:2665) at android.app.Activitythread.handleLaunchActivity(Activitythread.java:2726) at android.app.Activitythread. -wrap12(Activitythread.java) at android.app.Activitythread$H.handleMessage(Activitythread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.Activitythread.main(Activitythread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:886) at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:776) Caused by: android.view.Inflateexception: Binary XML file line #28: Binary XML file line #28: Error inflating class Fragment Caused by: android.view.Inflateexception: Binary XML file line #28: Error inflating class Fragment Caused by: java.lang.Classcastexception: Activity must implement Navigationdrawercallbacks. at com.fomedemais.Fomedemore.NavigationDrawerFragment.onAttach(Navigationdrawerfragment.java:73) at android.app.Fragment.onAttach(Fragment.java:1454) at android.app.Fragmentmanagerimpl.moveToState(Fragmentmanager.java:937) at android.app.Fragmentmanagerimpl.moveToState(Fragmentmanager.java:1149) at android.app.Fragmentmanagerimpl.addFragment(Fragmentmanager.java:1251) at android.app.Fragmentmanagerimpl.onCreateView(Fragmentmanager.java:2311) at android.app.Fragmentcontroller.onCreateView(Fragmentcontroller.java:98) at android.app.Activity.onCreateView(Activity.java:5901) at android.support.v4.app.Basefragmentactivityhoneycomb.onCreateView(Basefragmentactivityhoneycomb.java:34) at android.support.v4.app.Fragmentactivity.onCreateView(Fragmentactivity.java:78) at android.view.Layoutinflater.createViewFromTag(Layoutinflater.java:777) at android.view.Layoutinflater.createViewFromTag(Layoutinflater.java:727) at android.view.Layoutinflater.rInflate(Layoutinflater.java:858) at android.view.Layoutinflater.rInflateChildren(Layoutinflater.java:821) at android.view.Layoutinflater.rInflate(Layoutinflater.java:861) at android.view.Layoutinflater.rInflateChildren(Layoutinflater.java:821) at android.view.Layoutinflater.inflate(Layoutinflater.java:518) at android.view.Layoutinflater.inflate(Layoutinflater.java:426) at android.view.Layoutinflater.inflate(Layoutinflater.java:377) at android.support.v7.app.Appcompatdelegateimplv7.setContentView(Appcompatdelegateimplv7.java:255) at android.support.v7.app.Appcompatactivity.setContentView(Appcompatactivity.java:109) At com.fomedemais.Fomedemore.ComentariesActivity.onCreate(Commentosactivity.java:31) at android.app.Activity.performCreate(Activity.java:6679) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.Activitythread.performLaunchActivity(Activitythread.java:2618) at android.app.Activitythread.handleLaunchActivity(Activitythread.java:2726) at android.app.Activitythread. -wrap12(Activitythread.java) at android.app.Activitythread$H.handleMessage(Activitythread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.Activitythread.main(Activitythread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:886) at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:776)

  • The class Commentary really exists? Wouldn’t it be Comentariosactivity?

  • is I got it wrong kkk

  • But was that the problem? Solved?

  • In place of getcontext() puts Nomedaprimeiraactivity.this

  • In my system this getcontext(), returns me the context that in the case is the previous screen

  • Because the first is a Fragment

  • Try getActivity() in place of getcontext() then

  • I tried, it gave the same problem

  • Could be something in Entity ?

  • I thought it was for not registering in android manifest but I registered

  • @Leonardodias updated my question, adding more information

Show 7 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.