Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass "bitmap" as argument using safe args

I want to pass Bitmapas an argument to another fragment using safe args. what is the correct argType for passing a bitmap.

<fragment
        android:id="@+id/nextFragment"
        android:name="com.example.----.NextFragment"
        android:label="fragment_next"
        tools:layout="@layout/fragment_next" >
        <argument
            android:name="image"
            app:argType="???"
            android:defaultValue="???" />
</fragment>
like image 373
Askani Avatar asked Oct 26 '25 19:10

Askani


1 Answers

you can add argType as android.graphics.Bitmap

from the source code of NavType.java

Class clazz = Class.forName(className);
                if (Parcelable.class.isAssignableFrom(clazz)) {
                    return new ParcelableType(clazz);
                } else if (Enum.class.isAssignableFrom(clazz)) {
                    return new EnumType(clazz);
                } else if (Serializable.class.isAssignableFrom(clazz)) {
                    return new SerializableType(clazz);
                }

And Bitmap implements parcelable, so it will work.

You can remove the defaultValue

like image 185
Rahul Sharma Avatar answered Oct 28 '25 09:10

Rahul Sharma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!