在Android中共享应用程序“链接”

我希望我的应用程序用户能够分享/推荐我的应用程序给其他用户。 我使用ACTION_SEND意图。 我添加纯文本说一些沿线:安装这个很酷的应用程序。 但是我找不到让用户直接进入市场安装屏幕的方法。 我所能提供的只是一个网页链接或一些文本。 换句话说,我正在寻找一个非常直接的方式为Android用户安装我的应用程序。

感谢任何帮助/指针,

托马斯

这将让你从电子邮件,whastapp或其他任何select。

try { Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, "My application name"); String sAux = "\nLet me recommend you this application\n\n"; sAux = sAux + "https://play.google.com/store/apps/details?id=Orion.Soft \n\n"; i.putExtra(Intent.EXTRA_TEXT, sAux); startActivity(Intent.createChooser(i, "choose one")); } catch(Exception e) { //e.toString(); } 

托马斯,

您可能希望为用户提供market://链接,这些链接将直接将它们带到您的应用的详细信息页面。 以下是来自developer.android.com:

加载应用程序的详细信息页面

在Android Market中,每个应用程序都有一个“详细信息”页面,为用户提供应用程序概述。 例如,该页面包括应用程序的简短说明和正在使用的屏幕截图(如果由开发人员提供)以及来自用户的反馈和有关开发人员的信息。 “详细信息”页面还包含一个“安装”button,可让用户触发应用程序的下载/购买。

如果您想将用户引用到特定的应用程序,您的应用程序可以将用户直接带到应用程序的“详细信息”页面。 为此,您的应用程序将发送一个ACTION_VIEW Intent,其中包含以下格式的URI和查询参数:

市场://细节ID =

在这种情况下,packagename参数是应用程序清单文件中清单元素的package属性中声明的目标应用程序的完全限定包名称。 例如:

市场://细节ID = com.example.android.jetboy

资料来源: http : //developer.android.com/guide/publishing/publishing.html

更确切地说,

  Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.android.example")); startActivity(intent); 

或者如果你想分享你的开发其他应用程序。 你可以做这样的事情

 Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("https://play.google.com/store/apps/developer?id=Your_Publisher_Name")); startActivity(intent); 

调用这个方法:

 public static void shareApp(Context context) { final String appPackageName = context.getPackageName(); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "Check out Aap Ka Sewak App at: https://play.google.com/store/apps/details?id=" + appPackageName); sendIntent.setType("text/plain"); context.startActivity(sendIntent); } 

您也可以使用支持库中的ShareCompat类。

 ShareCompat.IntentBuilder.from(activity) .setType("text/plain") .setChooserTitle("Chooser title") .setText("http://play.google.com/store/apps/details?id=" + activity.getPackageName()) .startChooser(); 

https://developer.android.com/reference/android/support/v4/app/ShareCompat.html

要自动填写应用程序名称和应用程序ID,您可以使用这个:

 int applicationNameId = context.getApplicationInfo().labelRes; final String appPackageName = context.getPackageName(); Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, activity.getString(applicationNameId)); String text = "Install this cool application: "; String link = "https://play.google.com/store/apps/details?id=" + appPackageName; i.putExtra(Intent.EXTRA_TEXT, text + " " + link); startActivity(Intent.createChooser(i, "Share link:")); 

与标题共享应用程序是你的app_name,内容是你的应用程序链接

 private static void shareApp(Context context) { final String appPackageName = BuildConfig.APPLICATION_ID; final String appName = context.getString(R.string.app_name); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); String shareBodyText = "https://play.google.com/store/apps/details?id=" + appPackageName; shareIntent.putExtra(Intent.EXTRA_SUBJECT, appName); shareIntent.putExtra(Intent.EXTRA_TEXT, shareBodyText); context.startActivity(Intent.createChooser(shareIntent, context.getString(R.string .share_with))); } 

我知道这个问题已经得到解答,但我想分享一个替代解决scheme:

 Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); String shareSubText = "WhatsApp - The Great Chat App"; String shareBodyText = "https://play.google.com/store/apps/details?id=com.whatsapp&hl=en"; shareIntent.putExtra(Intent.EXTRA_SUBJECT, shareSubText); shareIntent.putExtra(Intent.EXTRA_TEXT, shareBodyText); startActivity(Intent.createChooser(shareIntent, "Share With")); 

最后这个代码是为我打开我们的android的电子邮件客户端。 试试这个片段。

 Intent testIntent = new Intent(Intent.ACTION_VIEW); Uri data = Uri.parse("mailto:?subject=" + "Feedback" + "&body=" + "Write Feedback here....." + "&to=" + "someone@example.com"); testIntent.setData(data); startActivity(testIntent); 

其实最好的方式来剪切你的用户之间的应用程序,谷歌(firebase)certificate了新技术Firebasedynamic链接通过几行你可以使它这是文档https://firebase.google.com/docs/dynamic-links/和代码是;

  Uri dynamicLinkUri = dynamicLink.getUri(); Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink() .setLink(Uri.parse("https://www.google.jo/")) .setDynamicLinkDomain("rw4r7.app.goo.gl") .buildShortDynamicLink() .addOnCompleteListener(this, new OnCompleteListener<ShortDynamicLink>() { @Override public void onComplete(@NonNull Task<ShortDynamicLink> task) { if (task.isSuccessful()) { // Short link created Uri shortLink = task.getResult().getShortLink(); Uri flowchartLink = task.getResult().getPreviewLink(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, shortLink.toString()); intent.setType("text/plain"); startActivity(intent); } else { // Error // ... } } });