MIUI does not send callback (#2279)

This commit is contained in:
南宫雪珊 2022-12-05 23:49:44 +08:00 committed by GitHub
parent 86d4722f80
commit fdff7f5aad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Process; import android.os.Process;
import android.system.Os; import android.system.Os;
@ -126,7 +127,8 @@ public class App extends Application {
private static OkHttpClient okHttpClient; private static OkHttpClient okHttpClient;
private static Cache okHttpCache; private static Cache okHttpCache;
private SharedPreferences pref; private SharedPreferences pref;
private final ExecutorService executorService = Executors.newCachedThreadPool(); private static final ExecutorService executorService = Executors.newCachedThreadPool();
private static final Handler MainHandler = new Handler(Looper.getMainLooper());
public static App getInstance() { public static App getInstance() {
return instance; return instance;
@ -144,6 +146,10 @@ public class App extends Application {
return !Process.isApplicationUid(Process.myUid()); return !Process.isApplicationUid(Process.myUid());
} }
public static Handler getMainHandler() {
return MainHandler;
}
@Override @Override
protected void attachBaseContext(Context base) { protected void attachBaseContext(Context base) {
super.attachBaseContext(base); super.attachBaseContext(base);

View File

@ -97,6 +97,12 @@ public class ShortcutUtil {
context.registerReceiver(receiver, filter, permission, context.registerReceiver(receiver, filter, permission,
null/* main thread */, Context.RECEIVER_NOT_EXPORTED); null/* main thread */, Context.RECEIVER_NOT_EXPORTED);
App.getMainHandler().postDelayed(() -> {
if (isLaunchShortcutPinned()) {
task.run();
}
}, 1000);
var intent = new Intent(uuid); var intent = new Intent(uuid);
int flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE; int flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
return PendingIntent.getBroadcast(context, 0, intent, flags).getIntentSender(); return PendingIntent.getBroadcast(context, 0, intent, flags).getIntentSender();