How to add Share App & More App Button Android Studio Java 2023

 


This tutorial explains step by step for how to add a Share Button/ Action in Android Application via Android Studio. Share button will help share our app content.


  • Share App
  • More App

Share App Button Source Code :

private void ShareApp(Context context){ // code here final String appPakageName = context.getPackageName(); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "Download Now : https://play.google.com/store/apps/details?id=" + appPakageName ); sendIntent.setType("text/plain"); context.startActivity(sendIntent); }

How to call Share App Method in your Button :


shareApp.setOnClickListener(v -> { // Code here ==== ShareApp(MainActivity.this); });


More App Button Source Code :


String developerName = "Atikul Software"; try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:" + developerName))); }catch (ActivityNotFoundException e){ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + developerName))); }


You can use this code any OnClickListener. It's easy and simple way to use Share App button and More App Button.

Post a Comment

Previous Post Next Post