Skip to main content

Share Button code in android studio

if you want  to send any text from recyclerview to whatsapp then  use this code.

 Intent intent = new Intent(Intent.ACTION_SEND);

intent.setType("text/plane");
intent.putExtra(Intent.EXTRA_TEXT, list.get(position).getText());
context.startActivity(intent);

if u want to send app link then use this code
Toast.makeText(getContext(), "Thanks for sharing", Toast.LENGTH_SHORT).show();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,"https://play.google.com/store/apps/details?id=com.ramsagar.quizzer");
sendIntent.setType("text/plain");
Intent shareIntent = Intent.createChooser(sendIntent,"Share Music world App");
startActivity(shareIntent);

Comments

Popular posts from this blog

Copy text code in android studio

for RecyclerView    ClipboardManager clipboardManager = ( ClipboardManager ) context .getSystemService( context . CLIPBOARD_SERVICE ); ClipData data = ( ClipData ) ClipData . newPlainText ( "Text" , list .get( position ).getText()); clipboardManager .setPrimaryClip( data ); Toast . makeText ( context , "Text Copied" , Toast . LENGTH_SHORT ).show(); for Activity private void copy (){ ClipboardManager clipboardManager = ( ClipboardManager ) getSystemService( Context . CLIPBOARD_SERVICE ); ClipData clipData = ClipData . newPlainText ( "text" , shayri_txt .getText()); if ( clipboardManager != null ){ clipboardManager .setPrimaryClip( clipData ); } Toast . makeText (getApplicationContext(), "Copied" , Toast . LENGTH_SHORT ).show(); }