From 0ccb35db674921f171ca250a9f4495659458c77f Mon Sep 17 00:00:00 2001 From: Joey Peter Date: Sun, 31 Jul 2022 20:41:07 +0200 Subject: [PATCH] fix: app crashes on reboot (#110) --- .../settingsmenu/ReVancedSettingsFragment.java | 7 +++---- .../apps/youtube/app/application/Shell_HomeActivity.java | 5 +++++ 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/google/android/apps/youtube/app/application/Shell_HomeActivity.java diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java index 932fb68a..5d4b3464 100644 --- a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java @@ -19,6 +19,7 @@ import android.preference.PreferenceScreen; import android.preference.SwitchPreference; import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; +import com.google.android.apps.youtube.app.application.Shell_HomeActivity; import java.util.ArrayList; import java.util.List; @@ -31,8 +32,6 @@ import app.revanced.integrations.videoplayer.AutoRepeat; public class ReVancedSettingsFragment extends PreferenceFragment { - public static Class homeActivityClass; - private List screens; private boolean Registered = false; @@ -210,12 +209,12 @@ public class ReVancedSettingsFragment extends PreferenceFragment { private void reboot(Activity activity, Class homeActivityClass) { int intent; intent = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE; - ((AlarmManager) activity.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME, 1500L, PendingIntent.getActivity(activity, 0, new Intent(activity, homeActivityClass), intent)); + ((AlarmManager) activity.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME, 1500L, PendingIntent.getActivity(activity, 0, new Intent(activity, Shell_HomeActivity.class), intent)); Process.killProcess(Process.myPid()); } private void rebootDialog(final Activity activity) { - new AlertDialog.Builder(activity).setMessage(getStringByName(activity, "pref_refresh_config")).setPositiveButton(getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> reboot(activity, ReVancedSettingsFragment.homeActivityClass)).setNegativeButton(getStringByName(activity, "sign_in_cancel"), null).show(); + new AlertDialog.Builder(activity).setMessage(getStringByName(activity, "pref_refresh_config")).setPositiveButton(getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> reboot(activity, Shell_HomeActivity.class)).setNegativeButton(getStringByName(activity, "sign_in_cancel"), null).show(); } private String getStringByName(Context context, String name) { diff --git a/app/src/main/java/com/google/android/apps/youtube/app/application/Shell_HomeActivity.java b/app/src/main/java/com/google/android/apps/youtube/app/application/Shell_HomeActivity.java new file mode 100644 index 00000000..52be6225 --- /dev/null +++ b/app/src/main/java/com/google/android/apps/youtube/app/application/Shell_HomeActivity.java @@ -0,0 +1,5 @@ +package com.google.android.apps.youtube.app.application; + +//dummy class +public class Shell_HomeActivity { +}