android - 将应用名称或文本链接到 Google Play 市场中的应用链接

标签 android google-play

我的应用程序中有一个分享按钮,而不是发送应用程序链接 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/

相关文章:

Android Studio、Gradle 根据 flavor 构建时使用不同的代码

android - 是否可以使用可绘制对象制作动画?

android - 如何在 MotionLayout 中以编程方式设置过渡持续时间?

Android:监听状态栏通知

java - 滚动时根据回收站 View 标题更改选项卡

android - 电子市场应用统计信息多久更新一次?

android - 跟踪 Android 市场统计数据

android - 应用程序按模块划分?

android - 如何调查 Xamarin/libmonosgen-2.0.so native 崩溃?

javascript - 删除 Android 应用程序 WebView 中的导航栏