0

enter image description hereI have a webview from which user can share a link to whatsapp but i want that when ever user share a link via whatsapp from webview my app name should also be sent in that text file . webview is in fragment

i want that my app name should be displayed in captions section "say something " and same on whats app or any other social media

i have tried

@Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {


                boolean overrideUrlLoading = false;

                if (url != null && url.startsWith("whatsapp://")) {
                    Intent text = new Intent();
                    Intent text1 = new Intent(Intent.ACTION_VIEW,  Uri.parse(url));
                    text.setAction("android.intent.action.SEND");
                    text.setType("text/plain");
                    text.putExtra("android.intent.extra.TEXT", "my app name ");


                    startActivity(text);
                    startActivity(text1);
                }

and this too

  @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {


                    boolean overrideUrlLoading = false;

                    if (url != null && url.startsWith("whatsapp://")) {

                        Intent text1 = new Intent(Intent.ACTION_VIEW,  Uri.parse(url));
                        startActivity(text1);
                        Intent text = new Intent();
                        text.setAction("android.intent.action.SEND");
                        text.setType("text/plain");
                        text.putExtra("android.intent.extra.TEXT", "my app name ");



                        startActivity(text);
                    }

i want to send my app name with the link (from webview) just like sharechat . any help ?? my app just send the link but it dont send my app name with that link

anshul raj
  • 173
  • 2
  • 17

4 Answers4

1

@anshul raj ///use this code its working properly

private void shareApp() {

        String appName = getString(R.string.app_name);
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
    String shareBodyText = "https://stackoverflow.com/questions/4969217/share-application-link-in-android"+"\n"+appName;

        shareIntent.putExtra(Intent.EXTRA_TEXT, shareBodyText);
        startActivity(Intent.createChooser(shareIntent,getString(R.string.app_name)));
    }
rachna
  • 124
  • 8
0

Try below code

text.putExtra("android.intent.extra.TEXT", getString(R.string.appname);

You can pass app name from string file.

help-info.de
  • 6,695
  • 16
  • 39
  • 41
Ashok Songara
  • 162
  • 1
  • 10
  • sorry to say but it is not working .check the image, i want that my app name is shown on that text "say something about it " – anshul raj Oct 10 '19 at 10:56
0

Use the below code to share text to WhatsApp

Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "my app name");
intent.setType("text/plain");
intent.setPackage("com.whatsapp");
startActivity(intent);
  • sorry to say but it is not working .check the image, i want that my app name is shown on that text "say something about it " – anshul raj Oct 10 '19 at 10:56
0

//postURL- this is URL of an article from a blog which I want to post on my facebook feed.

public void setupFacebookShareIntent(String postURL) {

        ShareDialog shareDialog;
        FacebookSdk.sdkInitialize(getApplicationContext());
        shareDialog = new ShareDialog(DetailedActivity.this);

        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentUrl(Uri.parse(postURL))

                .build();

        shareDialog.show(linkContent);
    }
Wasif Hamdani
  • 118
  • 11