java.lang.Runtimeexception: Parcel: Unable to marshal value

Asked

Viewed 489 times

0

I have this error when I click on a Recyclerview item and pass an object through Intent, already implemented Serializable and it didn’t work

 @Override
    public void onBindViewHolder(final ProcedimentoViewHolder viewHolder, final int position) {
        //Populando o Procedimento com o item na posição selecionada
        final Procedimento procedimento = mFilter.getProcedimentoFilter().get(position);
        //Setando as informações do adapterLayout na lista
        //holder é a o valor que o metodo onCreateViewHolder retorna, no caso a view com a referencia dos componentes
        viewHolder.titulo.setText(procedimento.getTitulo());
        viewHolder.itemView.setTag(procedimento);
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                HashMap<String, Procedimento> mapProcedimento = new HashMap<String, Procedimento>();
                mapProcedimento.put("Procedimento", procedimento);
                Intent intent = new Intent(context, ProcedimentoActivity.class);
                intent.putExtra("mapProcedimento", mapProcedimento);
                context.startActivity(intent);
            }
        });
    }





05-19 14:57:24.058 2994-2994/com.basedeconhecimento E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: com.basedeconhecimento, PID: 2994
                                                                                java.lang.RuntimeException: Parcel: unable to marshal value com.basedeconhecimento.Modelo.Procedimento@35c8dce
                                                                                    at android.os.Parcel.writeValue(Parcel.java:1477)
                                                                                    at android.os.Parcel.writeMapInternal(Parcel.java:698)
                                                                                    at android.os.Parcel.writeMap(Parcel.java:682)
                                                                                    at android.os.Parcel.writeValue(Parcel.java:1389)
                                                                                    at android.os.Parcel.writeArrayMapInternal(Parcel.java:724)
                                                                                    at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)
                                                                                    at android.os.Bundle.writeToParcel(Bundle.java:1157)
                                                                                    at android.os.Parcel.writeBundle(Parcel.java:764)
                                                                                    at android.content.Intent.writeToParcel(Intent.java:8687)
                                                                                    at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3082)
                                                                                    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1518)
                                                                                    at android.app.Activity.startActivityForResult(Activity.java:4225)
                                                                                    at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
                                                                                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
                                                                                    at android.app.Activity.startActivityForResult(Activity.java:4183)
                                                                                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
                                                                                    at android.app.Activity.startActivity(Activity.java:4522)
                                                                                    at android.app.Activity.startActivity(Activity.java:4490)
                                                                                    at com.stefanini.basedeconhecimento.Adapter.ProcedimentoAdapter$1.onClick(ProcedimentoAdapter.java:71)
                                                                                    at android.view.View.performClick(View.java:5637)
                                                                                    at android.view.View$PerformClick.run(View.java:22429)
                                                                                    at android.os.Handler.handleCallback(Handler.java:751)
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                    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)

Who can help, thank you very much

  • 1

    Michael, because you need to pass a map to the other Activity, is there a specific reason? My suggestion is to pass the object directly in Extras. In addition, the class Procedimento implements Parcelable or Serializable?

1 answer

-1

All objects in the Collections class implement Serializable. So, probably the error is in implementing the serializable interface of the Procedure class.

Browser other questions tagged

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