我的应用程序中有一个分享按钮,而不是发送应用程序链接 http://play.google.com/store/apps/details?id=<package_name>
通过 Intent ACTION_SEND
我想将 Play 商店中的应用程序链接链接到一个文本(应用程序名称)。因此接收者将看到一个名称,然后单击该名称将重定向到 Play 商店中的应用程序。我该如何实现?
SpannableString s = new SpannableString("http://play.google.com/store/apps/details?id={packageName}");
Linkify.addLinks(s, Linkify.ALL);
String messStr = "Check out this event: " + eventObj.getString(Configs.EVENTS_TITLE) + " | from #AppName "+"\n"+s +"\n";
Bitmap bitmap = ((BitmapDrawable) eImg.getDrawable()).getBitmap();
Uri uri = getImageUri(EventDetails.this, bitmap);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.putExtra(Intent.EXTRA_TEXT, messStr);
startActivity(Intent.createChooser(intent, "Share on..."));
最佳答案
更新版本:用户更改包名
您有按钮,可以将文本设置为您想要的任何内容,然后将 onClick 方法设置为播放商店
///You need to set an EditText attribute in your layout, similar to how you set the button
packageName = (EditText) findViewById(R.id.edit);
Button button = (Button) findViewById(R.id.button_id);
//locates button from xml layout file
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Tries to open the play store to your listing
String str = packagename.getText().toString();
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + str)));
}
catch (ActivityNotFoundException e1)
{
//catches error if play store isn't found
Toast.makeText(this, "Play Store not installed", Toast.LENGTH_SHORT).show();
}
}
});
这在理论上应该可行。
关于android - 将应用名称或文本链接到 Google Play 市场中的应用链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41924764/