Android 如何通过消息共享应用程序共享应用程序链接

Android 如何通过消息共享应用程序共享应用程序链接,android,Android,对于我的申请,我想提供股票期权 为此,我编辑了文本以提供电话号码和共享按钮。若用户提供了一个有效的号码并单击了共享按钮,那个么所有可用的消息发送应用程序的列表都应该列出。如果用户从列表中选择应用程序,则带有应用程序链接的消息应使用所选应用程序向其手机发送 我如何实现这一点?请帮忙 试试下面的代码,这正是您想要的 Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND);

对于我的申请,我想提供股票期权

为此,我编辑了文本以提供电话号码和共享按钮。若用户提供了一个有效的号码并单击了共享按钮,那个么所有可用的消息发送应用程序的列表都应该列出。如果用户从列表中选择应用程序,则带有应用程序链接的消息应使用所选应用程序向其手机发送


我如何实现这一点?请帮忙

试试下面的代码,这正是您想要的

  Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_TEXT, "message link");
            sendIntent.setType("text/plain");
            startActivity(Intent.createChooser(sendIntent, "Chooser title text"));
       Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.ACTION_SEND);
                sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, Your_EditText_object.getText().toString());
                sendIntent.setType("text/plain");
                startActivity(Intent.createChooser(sendIntent, "Your Title"));
试试这个

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,"your application link"));
startActivity(Intent.createChooser(sharingIntent,"Share using"));
试试这个:

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
参考链接:

public static void callShare(Context theCtx, String theImagePath, String theText) 
    {
        // Pass the message and Image path that you want to share
                File myImageFile = new File(theImagePath);
        String shareBody = theText;  //"Here is the share content body " ;
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        if (myImageFile.exists()) {
            // email address is required to be filled.
                        sharingIntent.setType("image/jpeg");
            // "file://" and .getAbsolutePath is very important for Extra_Stream.
            sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + myImageFile.getAbsolutePath()));
        } else if (!theText.isEmpty()) {
            sharingIntent.setType("text/*");
        }
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, ""); //"Subject here"
        sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
        sharingIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        theCtx.startActivity(Intent.createChooser(sharingIntent, "Share via"));
    }