- // The public interface is used to send information back to the parent activity.
- public interface PinnedMismatchListener {
- void onPinnedMismatchBack();
-
- void onPinnedMismatchProceed();
- }
-
- // Check to make sure that the parent activity implements the listener.
- public void onAttach(Context context) {
- // Run the default commands.
- super.onAttach(context);
-
- // Get a handle for `PinnedSslCertificateMismatchListener` from the launching context.
- pinnedMismatchListener = (PinnedMismatchListener) context;
- }
-
- public static PinnedMismatchDialog displayDialog(long webViewFragmentId, Bitmap favoriteIconBitmap) {
- // 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();
-