+
+ // Create a favorite icon byte array output stream.
+ ByteArrayOutputStream favoriteIconByteArrayOutputStream = new ByteArrayOutputStream();
+
+ // Convert the favorite icon to a PNG and place it in the byte array output stream. `0` is for lossless compression (the only option for a PNG).
+ favoriteIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, favoriteIconByteArrayOutputStream);
+
+ // Convert the byte array output stream to a byte array.
+ byte[] favoriteIconByteArray = favoriteIconByteArrayOutputStream.toByteArray();
+
+ // Create a bundle.
+ Bundle bundle = new Bundle();
+
+ // Store the variables in the bundle
+ bundle.putString("url", url);
+ bundle.putString("title", title);
+ bundle.putByteArray("favorite_icon_byte_array", favoriteIconByteArray);
+
+ // Create a new instance of the dialog.
+ CreateBookmarkDialog createBookmarkDialog = new CreateBookmarkDialog();
+
+ // Add the bundle to the dialog.
+ createBookmarkDialog.setArguments(bundle);
+
+ // Return the new dialog.
+ return createBookmarkDialog;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ // Run the default commands.
+ super.onCreate(savedInstanceState);
+
+ // Get the arguments.
+ Bundle arguments = getArguments();
+
+ // Remove the incorrect lint warning below that the arguments might be null.
+ assert arguments != null;
+
+ // Store the contents of the arguments in class variables.
+ url = arguments.getString("url");
+ title = arguments.getString("title");
+
+ // Get the favorite icon byte array.
+ byte[] favoriteIconByteArray = arguments.getByteArray("favorite_icon_byte_array");
+
+ // Remove the incorrect lint warning below that the favorite icon byte array might be null.
+ assert favoriteIconByteArray != null;
+
+ // Convert the favorite icon byte array to a bitmap and store it in a class variable.
+ favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.length);