我想使用what's app或facebook等向某些用户分享产品的url,产品名称。当用户单击该产品时,如果安装了应用程序,则应打开应用程序中的相同产品页面。如果未安装应用程序,则应导航到播放商店。现在如何生成该可共享链接,以便在用户单击时打开应用程序中的同一页面
这是我的代码
// 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;
}