Use ShareCompat.IntentBuilder to compose share intent.
This commit is contained in:
parent
b4f1f44c28
commit
7eead38f52
|
@ -5,9 +5,12 @@ import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import androidx.core.content.FileProvider;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.app.ShareCompat;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -23,11 +26,13 @@ public class ShareUtils {
|
||||||
private ShareUtils() {
|
private ShareUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void shareLink(Context context, String text) {
|
public static void shareLink(@NonNull Context context, @NonNull String text) {
|
||||||
Intent i = new Intent(Intent.ACTION_SEND);
|
Intent intent = new ShareCompat.IntentBuilder(context)
|
||||||
i.setType("text/plain");
|
.setType("text/plain")
|
||||||
i.putExtra(Intent.EXTRA_TEXT, text);
|
.setText(text)
|
||||||
context.startActivity(Intent.createChooser(i, context.getString(R.string.share_url_label)));
|
.setChooserTitle(R.string.share_url_label)
|
||||||
|
.createChooserIntent();
|
||||||
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void shareFeedlink(Context context, Feed feed) {
|
public static void shareFeedlink(Context context, Feed feed) {
|
||||||
|
|
Loading…
Reference in New Issue