From 4eee987d32fc1108a44faecfe66bb990e1e4aba3 Mon Sep 17 00:00:00 2001 From: Luv Letter Date: Wed, 28 Jun 2023 23:31:12 -0400 Subject: [PATCH] use ShareCompat to fix sharing QQ/Weixin files from Island (#13) --- .../linesoft/open2share/ReceiveOpenActivity.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/top/linesoft/open2share/ReceiveOpenActivity.java b/app/src/main/java/top/linesoft/open2share/ReceiveOpenActivity.java index aa3cb49..94f5527 100644 --- a/app/src/main/java/top/linesoft/open2share/ReceiveOpenActivity.java +++ b/app/src/main/java/top/linesoft/open2share/ReceiveOpenActivity.java @@ -5,6 +5,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ShareCompat; public class ReceiveOpenActivity extends AppCompatActivity { @@ -35,16 +36,10 @@ protected void onCreate(Bundle savedInstanceState) { //setContentView(R.layout.activity_receive_open); //Toast.makeText(this,"已经将打开文件转换为分享文件",Toast.LENGTH_LONG).show(); - Intent sendIntent = new Intent(); - sendIntent.setAction(Intent.ACTION_SEND); - //sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - sendIntent.addCategory("android.intent.category.DEFAULT"); -// Log.d("分享","Data:"+ getIntent().getData().toString()); -// Log.d("分享","Type:"+ getIntent().getType()); - sendIntent.putExtra(Intent.EXTRA_STREAM, getIntent().getData()); - sendIntent.setType(getIntent().getType()); - startActivityForResult(Intent.createChooser(sendIntent,getString(R.string.share_title)),1); - //finish(); + new ShareCompat.IntentBuilder(this) + .addStream(getIntent().getData()) + .setType(getIntent().getType()) + .startChooser(); } }