在网络视图中通过Facebook和WhatsApp共享

问题描述:

我有一个Webview,用户可以从中共享指向whatsapp的链接,但是我希望当用户通过webs通过whatsapp共享链接时,我的应用名称也应发送到该文本文件。 webview是片段

I 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

我希望我的应用名称显示在标题部分说些什么上,并在whats应用或任何其他社交媒体上显示相同的名称

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

我尝试过

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

  @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 // /使用此代码可以正常工作

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