Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

[#246] hide API Compatibility warning dialog (Settings page) #380

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@

import java.io.ByteArrayInputStream;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -286,6 +289,9 @@ public void onCreate() {
if (BuildConfig.DEBUG) {
Stetho.initializeWithDefaults(this);
}

hideAndroidApiCompatibilityWarningDialog();

setupFirebaseRemoteConfig();
OpenStreetMapTileProviderConstants.setUserAgentValue(BuildConfig.APPLICATION_ID);

Expand Down Expand Up @@ -512,4 +518,26 @@ public void onComplete(@NonNull Task<Void> task) {
}


private void hideAndroidApiCompatibilityWarningDialog(){
try {
Class aClass = Class.forName("android.content.pm.PackageParser$Package");
Constructor declaredConstructor = aClass.getDeclaredConstructor(String.class);
declaredConstructor.setAccessible(true);
} catch (Exception e) {
e.printStackTrace();
}
try {
Class cls = Class.forName("android.app.ActivityThread");
Method declaredMethod = cls.getDeclaredMethod("currentActivityThread");
declaredMethod.setAccessible(true);
Object activityThread = declaredMethod.invoke(null);
Field mHiddenApiWarningShown = cls.getDeclaredField("mHiddenApiWarningShown");
mHiddenApiWarningShown.setAccessible(true);
mHiddenApiWarningShown.setBoolean(activityThread, true);
} catch (Exception e) {
e.printStackTrace();
}
}


}