From bd791dcc56beb831b03da11b18fda71e239f5c5f Mon Sep 17 00:00:00 2001 From: ningwenqiang Date: Tue, 5 Nov 2024 15:46:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=9A=84=E5=AE=98=E5=8D=9A?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yunbao/share/AbsShareInterface.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Share/src/main/java/com/yunbao/share/AbsShareInterface.java b/Share/src/main/java/com/yunbao/share/AbsShareInterface.java index dbae5135a..141191dbb 100644 --- a/Share/src/main/java/com/yunbao/share/AbsShareInterface.java +++ b/Share/src/main/java/com/yunbao/share/AbsShareInterface.java @@ -3,7 +3,9 @@ package com.yunbao.share; import android.content.Context; import android.content.IntentFilter; import android.net.Uri; +import android.os.Build; +import androidx.annotation.RequiresApi; import androidx.core.content.FileProvider; import com.twitter.sdk.android.tweetcomposer.TweetUploadService; @@ -15,12 +17,22 @@ import java.io.File; public abstract class AbsShareInterface { protected final Context mContext; + public AbsShareInterface(Context context) { this.mContext = context; IntentFilter filter = new IntentFilter(TweetUploadService.UPLOAD_SUCCESS); filter.addAction(TweetUploadService.UPLOAD_FAILURE); filter.addAction(TweetUploadService.TWEET_COMPOSE_CANCEL); - context.registerReceiver(new TwitterResultReceiver(), filter); + + TwitterResultReceiver receiver = new TwitterResultReceiver(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + // Android 12 (API 33) 及以上版本 + context.registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED); + } else { + // Android 12 (API 33) 以下版本 + context.registerReceiver(receiver, filter); + } } public abstract void share(ShareBean builder, ICallback callback);