share via facebook and whatsapp in web view

后端 未结 3 1712
天涯浪人
天涯浪人 2021-01-16 23:14

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 t

相关标签:
3条回答
  • 2021-01-16 23:30

    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);
    
    0 讨论(0)
  • 2021-01-16 23:40

    Try below code

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

    You can pass app name from string file.

    0 讨论(0)
  • 2021-01-16 23:50

    @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)));
        }
    
    0 讨论(0)
提交回复
热议问题