How do I share an app with a link in android studio ?
In this tutorial I will explain with example How do I share an app with a link in android studio ?
Follow these steps to send your app link in android studio
Step 1 - Design Your layout with share Button
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
android:id="@+id/shareBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Share App With link" />
</LinearLayout>
Step 3 - Write code in .java file in onCreate Method for share link
Button shareBtn = findViewById(R.id.shareBtn);
shareBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_TEXT,"https://play.google.com/store/apps/details?id="+getPackageName());
startActivity(Intent.createChooser(intent, "Share")); }
});
}
