Typically, the ACTION_SEND action sends the URL of the build-in browser app. When sharing data, the Intent call createChooser () method that takes the Intent object and specifies the title of the selector dialog. The intent.createChooser () method allows the selector to be displayed.
Now you can share the app link wherever you want, you can use this method in Navigation Drawer and Main Menu, hope that this article will be very useful for you. Thank you.Now you can share the app link wherever you want, you can use this method in Navigation Drawer and Main Menu, hope that this article will be very useful for you.
- First First Create another undertaking in Android Studio
- File ⇒ New ⇒ Application Project
- Then Open app -> package -> MainActivity.java and then add following code :
Java(MainActivity.java)
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
private Button shareApp;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
shareApp=findViewById(R.id.share_button);
shareApp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT,"Write what you want");
String app_url = " https://play.google.com/store/apps/details?id=com.example.projectname"; // Write your app package name after id
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,app_url);
startActivity(Intent.createChooser(shareIntent, "Share with"));
});
}
}
}
Now Open res folder again layout and next again activity_main.xml and then add following code : :XML (activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/share_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SHARE APP"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
This is also useful for you- How to Create Image Slider using ViewPager in android studio
- How to create Swipeable Videos Like TikTok Using ViewPager2 in andriod studio
- how to get all audio files in android programmatically
- How to use SearchView in andriod studio
- How to check internet Connection in androd studio
- How to Create Bottom Sheet in android studio
- How to Refresh a list Using RecyclerView in Android Studio
- How to create Welcome Splash Screen with animation in android studio
- How to create menu and sub menu in android studio
- How to create a list item with RecyclerView in Android Studio
- BottomNavigationView android example
- How to create Text to Speech app in android studio Toward the end, you run this undertaking and see the yield.
A screen capture is given underneath with the goal that you can perceive how the work.
Now you can share the app link wherever you want, you can use this method in Navigation Drawer and Main Menu, hope that this article will be very useful for you. Thank you.Now you can share the app link wherever you want, you can use this method in Navigation Drawer and Main Menu, hope that this article will be very useful for you.
Thank you...
0 Comments
Please do not enter any spam link in the comment box
Emoji