Why when I start Activity does the app close?

0

I have in my onClick method the button to open the Activity within the PagerCronActivityActivity, as follows.

Bundle args = new Bundle();
Intent i = new Intent(CadastroProntuarioActivity.this, ProntuarioActivity.class);

args.putString("nomeCompleto", atributosDeConfirma.getNomeCompleto());
args.putByteArray("fotoPerfil", atributosDeConfirma.getFotoArrayByte());

i.putExtras(args);
startActivity(i);

I want to direct to ProntuarioActivity, however the application closes when the startActivity (i) method is called.

OnCreate of the ProntuarioActivity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_prontuario);
    usuario = new Usuario();
    listaPacientes = new ArrayList<Paciente>();
    paciente = new Paciente();
    carregarPaciente();

    //SETANDO O TOOLBAR
    mToolbar = (Toolbar) findViewById(R.id.toolbar_prontuario);
    setSupportActionBar(mToolbar);

    //CRIANDO OS PERFIS
    final IProfile perfilUsuario = new ProfileDrawerItem().withName(paciente.getNome()).withIcon(Conversor.convertByteArrayToDrawable(paciente.getFoto())).withEmail(usuario.getEmail()).withIdentifier(100);
    // final IProfile perfil2 = new ProfileDrawerItem().withName("Tiago Ferezin").withIcon(getResources().getDrawable(R.drawable.profile2)).withIdentifier(101);
    // final IProfile perfil3 = new ProfileDrawerItem().withName("Flávio Barbosa").withIcon(getResources().getDrawable(R.drawable.profile3)).withIdentifier(102);

    final IProfile[] perfis = carregarPerfis(listaPacientes);
    mAccountHeader = new AccountHeaderBuilder()
            .withActivity(this)
            .withHeaderBackground(getResources().getDrawable(R.drawable.header))
            .addProfiles(
                    perfilUsuario,
                    new ProfileSettingDrawerItem().withName("Adicionar Prontuário").withDescription("Adicionar Novo Prontuário").withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_plus).actionBar().paddingDp(5).colorRes(R.color.material_drawer_primary_text)).withIdentifier(PROFILE_SETTING),
                    new ProfileSettingDrawerItem().withName("Configurar Conta").withIcon(GoogleMaterial.Icon.gmd_settings)
            )
            .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
                @Override
                public boolean onProfileChanged(View view, IProfile profile, boolean current) {
                    //sample usage of the onProfileChanged listener
                    //if the clicked item has the identifier 1 add a new profile ;)
                    if (profile instanceof IDrawerItem && ((IDrawerItem) profile).getIdentifier() == PROFILE_SETTING) {
                        int count = 100 + mAccountHeader.getProfiles().size() + 1;
                        Intent intentCadProntuario = new Intent(ProntuarioActivity.this, CadastroProntuarioActivity.class);
                        startActivity(intentCadProntuario);
                        IProfile newProfile = new ProfileDrawerItem().withNameShown(true).withName("Flávio Barbosa" + count).withEmail("Flávio Barbosa" + count + "@gmail.com").withIcon(R.drawable.profile4).withIdentifier(count);
                        if (mAccountHeader.getProfiles() != null) {
                            //we know that there are 2 setting elements. set the new profile above them ;)
                            mAccountHeader.addProfile(newProfile, mAccountHeader.getProfiles().size() - 2);
                        } else {
                            mAccountHeader.addProfiles(newProfile);
                        }
                    }

                    //false if you have not consumed the event and it should close the drawer
                    return false;
                }
            })
            .withSavedInstance(savedInstanceState)
            .build();

    mDrawerLeft = new DrawerBuilder()
            .withActivity(this)
            .withDisplayBelowStatusBar(false)
            .withActionBarDrawerToggleAnimated(true)
            .withToolbar(mToolbar)
            .withHasStableIds(true)
            .withAccountHeader(mAccountHeader) //set the AccountHeader we created earlier for the header
            .addDrawerItems(
                    new PrimaryDrawerItem().withName("Compact").withDescription("Normal").withIcon(GoogleMaterial.Icon.gmd_sun).withIdentifier(1).withSelectable(false),
                    new PrimaryDrawerItem().withName("action").withDescription("Acao").withIcon(FontAwesome.Icon.faw_home).withIdentifier(2).withSelectable(false),
                    new PrimaryDrawerItem().withName("multiitem").withDescription("multi").withIcon(FontAwesome.Icon.faw_gamepad).withIdentifier(3).withSelectable(false)
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    return false;
                }
            })
            .withSavedInstance(savedInstanceState)
            .withShowDrawerOnFirstLaunch(true)
            .build();

    RecyclerViewCacheUtil.getInstance().withCacheSize(2).init(mDrawerLeft);

    if (savedInstanceState == null) {
        // set the selection to the item with the identifier 11
        mDrawerLeft.setSelection(21, false);

        //set the active profile
        mAccountHeader.setActiveProfile(perfilUsuario);
    }

    mDrawerLeft.updateBadge(4, new StringHolder(10 + ""));

}

How do I solve this problem?

    
asked by anonymous 01.02.2016 / 16:42

1 answer

2

I solved the problem by persisting the data I would pass to the Bundle in the database and then recovering, since everything seems to overload the Bundle. This varies from device to device.

    
02.02.2016 / 19:06