Fix crash
This commit is contained in:
parent
0dc89c1148
commit
38a6d3c9c1
|
|
@ -48,27 +48,23 @@ public class Init {
|
||||||
get().handler.post(() -> Toast.makeText(context(), msg, Toast.LENGTH_LONG).show());
|
get().handler.post(() -> Toast.makeText(context(), msg, Toast.LENGTH_LONG).show());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Activity getActivity() {
|
public static Activity getActivity() throws Exception {
|
||||||
try {
|
Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
||||||
Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
|
||||||
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
|
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
|
||||||
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
|
activitiesField.setAccessible(true);
|
||||||
activitiesField.setAccessible(true);
|
Map<?, ?> activities = (Map<?, ?>) activitiesField.get(activityThread);
|
||||||
Map<?, ?> activities = (Map<?, ?>) activitiesField.get(activityThread);
|
for (Object activityRecord : activities.values()) {
|
||||||
for (Object activityRecord : activities.values()) {
|
Class<?> activityRecordClass = activityRecord.getClass();
|
||||||
Class<?> activityRecordClass = activityRecord.getClass();
|
Field pausedField = activityRecordClass.getDeclaredField("paused");
|
||||||
Field pausedField = activityRecordClass.getDeclaredField("paused");
|
pausedField.setAccessible(true);
|
||||||
pausedField.setAccessible(true);
|
if (!pausedField.getBoolean(activityRecord)) {
|
||||||
if (!pausedField.getBoolean(activityRecord)) {
|
Field activityField = activityRecordClass.getDeclaredField("activity");
|
||||||
Field activityField = activityRecordClass.getDeclaredField("activity");
|
activityField.setAccessible(true);
|
||||||
activityField.setAccessible(true);
|
Activity activity = (Activity) activityField.get(activityRecord);
|
||||||
Activity activity = (Activity) activityField.get(activityRecord);
|
SpiderDebug.log(activity.getComponentName().getClassName());
|
||||||
SpiderDebug.log(activity.getComponentName().getClassName());
|
return activity;
|
||||||
return activity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,13 +163,19 @@ public class Misc {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addView(View view, ViewGroup.LayoutParams params) {
|
public static void addView(View view, ViewGroup.LayoutParams params) {
|
||||||
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
try {
|
||||||
group.addView(view, params);
|
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
|
group.addView(view, params);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeView(View view) {
|
public static void removeView(View view) {
|
||||||
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
try {
|
||||||
group.removeView(view);
|
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
|
group.removeView(view);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadWebView(String url, WebViewClient client) {
|
public static void loadWebView(String url, WebViewClient client) {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
906b337d4b4baef13292d004e5fd8f9b
|
487834a2d0d9aa7614beeba237cce0c2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue