Also support lower android version
This commit is contained in:
parent
eb3afb0057
commit
3e5101aab8
3 changed files with 28 additions and 10 deletions
|
@ -5,8 +5,8 @@ android {
|
|||
compileSdk rootProject.ext.compileSdkVersion
|
||||
defaultConfig {
|
||||
applicationId "org.mapcomplete"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
minSdk 30
|
||||
targetSdkVersion targetSdkVersion
|
||||
versionCode 9
|
||||
versionName "debug"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-sdk tools:overrideLibrary="com.getcapacitor.android, capacitor.cordova.android.plugins" />
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
|
|
@ -79,16 +79,33 @@ public class MainActivity extends BridgeActivity {
|
|||
Databridge.sendAnswerTo(responder, json);
|
||||
});
|
||||
|
||||
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_OVERLAY,
|
||||
() -> {
|
||||
System.out.println("Back button pressed");
|
||||
if (this.backbutton != null) {
|
||||
Databridge.sendAnswerTo(this.backbutton, "backbutton pressed");
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_OVERLAY,
|
||||
() -> {
|
||||
System.out.println("Back button pressed");
|
||||
if (this.backbutton != null) {
|
||||
Databridge.sendAnswerTo(this.backbutton, "backbutton pressed");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
||||
System.out.println("Back button pressed (old)");
|
||||
if (this.backbutton != null) {
|
||||
Databridge.sendAnswerTo(this.backbutton, "backbutton pressed");
|
||||
}
|
||||
}else{
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean hasGeolocationPermission() {
|
||||
return ContextCompat.checkSelfPermission(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue