在Android中分享应用功能

时间:2016-05-12 14:30:36

标签: android android-sharing

我如何实施'分享应用程序' android中的功能。我看到很多网站,但都展示了如何共享文件,多媒体等。但没有适当的代码来共享应用程序本身。有人可以帮帮我吗?

2 个答案:

答案 0 :(得分:4)

您可以使用以下代码

 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();
    }  

答案 1 :(得分:0)

You can try the below code for sharing your application : 
 try {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_SUBJECT, "Your app name");
            String s = "\n Your app recommendation text here\n\n";
            s = s + "Your string to mention here(may be playstore url)";
            i.putExtra(Intent.EXTRA_TEXT, sAux);
            mActivity.startActivity(Intent.createChooser(i, "choose to share"));
        } catch(Exception e) {
            //e.toString();
            e.printStackTrace();
        }