I want share url of product, product name to some user using either what's app or facebook etc.when user clicks on that product same product page in app should be opened if app is installed. if app is not installed it should navigate to play store.Now how to generate that sharable link so that same page in app should be opened when user clicks
Here is my code
// share on social websites
public void shareItem(String url) {
Log.e("image",productimage);
Picasso.with(getApplicationContext()).load(url).into(new Target() {
@Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("*/*");
i.putExtra(Intent.EXTRA_STREAM, getLocalBitmapUri(bitmap));
i.putExtra(Intent.EXTRA_TEXT, name.getText().toString()+ "\n" +productimage);
startActivity(Intent.createChooser(i, "Share Image"));
}
@Override public void onBitmapFailed(Drawable errorDrawable) { }
@Override public void onPrepareLoad(Drawable placeHolderDrawable) { }
});
}
public Uri getLocalBitmapUri(Bitmap bmp) {
Uri bmpUri = null;
try {
File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "share_image_" + System.currentTimeMillis() + ".png");
FileOutputStream out = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
out.close();
//bmpUri = Uri.fromFile(file);
bmpUri=FileProvider.getUriForFile(getApplication(),BuildConfig.APPLICATION_ID+".provider",file);
} catch (IOException e) {
e.printStackTrace();
}
return bmpUri;
}