fix: app crashes on reboot (#110)

This commit is contained in:
Joey Peter 2022-07-31 20:41:07 +02:00 committed by GitHub
parent d7833ec2e7
commit 0ccb35db67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -19,6 +19,7 @@ import android.preference.PreferenceScreen;
import android.preference.SwitchPreference; import android.preference.SwitchPreference;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; 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.ArrayList;
import java.util.List; import java.util.List;
@ -31,8 +32,6 @@ import app.revanced.integrations.videoplayer.AutoRepeat;
public class ReVancedSettingsFragment extends PreferenceFragment { public class ReVancedSettingsFragment extends PreferenceFragment {
public static Class homeActivityClass;
private List<PreferenceScreen> screens; private List<PreferenceScreen> screens;
private boolean Registered = false; private boolean Registered = false;
@ -210,12 +209,12 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
private void reboot(Activity activity, Class homeActivityClass) { private void reboot(Activity activity, Class homeActivityClass) {
int intent; int intent;
intent = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE; 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()); Process.killProcess(Process.myPid());
} }
private void rebootDialog(final Activity activity) { 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) { private String getStringByName(Context context, String name) {

View File

@ -0,0 +1,5 @@
package com.google.android.apps.youtube.app.application;
//dummy class
public class Shell_HomeActivity {
}