I'm new to android. I want to pass bitmap into Bundle. But I can't find any solution for it. Actually, I'm confused. I want to display an image in a Dialog fragment. But I don't know how to put into Bundle. Should I send as PutByteArray()
? But if I pass bitmap as an argument, it is stating as a wrong argument.
Here is my code:
public class MyAlert extends DialogFragment {
Bitmap b;
public MyAlert newInstance(Bitmap b) {
this.b=b;
MyAlert frag=new MyAlert();
Bundle args=new Bundle();
args.put("bitByte",b);
frag.setArguments(args);
return frag;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bitmap bitmap=getArguments().getByteArray("bitByte");
return new AlertDialog().Builder(getActivity());
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setView(R.id.fragid).create();