Skip to content

Commit

Permalink
fix: app crashes on reboot (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJeterLP authored Jul 31, 2022
1 parent d7833ec commit 0ccb35d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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;
Expand All @@ -31,8 +32,6 @@

public class ReVancedSettingsFragment extends PreferenceFragment {

public static Class homeActivityClass;

private List<PreferenceScreen> screens;

private boolean Registered = false;
Expand Down Expand Up @@ -210,12 +209,12 @@ private String getPackageName() {
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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.google.android.apps.youtube.app.application;

//dummy class
public class Shell_HomeActivity {
}

0 comments on commit 0ccb35d

Please sign in to comment.