I want to show a popup before sharing a text on WhatsApp if the users have two whatsapp.
Like this:
Here is code:
try {
FileOutputStream outputStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
outputStream.flush();
outputStream.close();
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("image/*");
i.setPackage("com.whatsapp");
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String shareMessage = newsModel.getTitle() + "\n\n" + "That's Awesome...\uD83D\uDC40 \n\n Install Now!☺☺ \n\n";
shareMessage = shareMessage + "https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID + "\n\n";
i.putExtra(Intent.EXTRA_TEXT, shareMessage);
startActivity(Intent.createChooser(i, "Share News from " + this.getString(R.string.app_name)));
} catch (Exception e) {
Log.e("ContentValue", e.getMessage());
try {
FileOutputStream outputStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
outputStream.flush();
outputStream.close();
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("image/*");
i.setPackage("com.whatsapp.w4b");
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String shareMessage = newsModel.getTitle() + "\n\n" + "That's Awesome...\uD83D\uDC40 \n\n Install Now!☺☺ \n\n";
shareMessage = shareMessage + "https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID + "\n\n";
i.putExtra(Intent.EXTRA_TEXT, shareMessage);
startActivity(Intent.createChooser(i, "Share News from " + this.getString(R.string.app_name)));
} catch (Exception exception) {
exception.printStackTrace();
}
}
This code works properly to share text on WhatsApp but the problem is through this code WhatsApp opens directly and the popup does not show. I want to show the popup as the given picture below please help me solve this problem.
