diff --git a/package.json b/package.json index a0c90c35..4ffee665 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cordova-plugin-background-mode", - "version": "0.7.3", - "description": "Prevent apps from going to sleep in background.", + "version": "0.7.4", + "description": "Prevent apps from going to sleep in background. Support for capacitor", "cordova": { "id": "cordova-plugin-background-mode", "platforms": [ @@ -38,4 +38,4 @@ "url": "https://github.com/katzer/cordova-plugin-background-mode/issues" }, "homepage": "https://github.com/katzer/cordova-plugin-background-mode#readme" -} \ No newline at end of file +} diff --git a/src/android/BackgroundModeExt.java b/src/android/BackgroundModeExt.java index ed765984..38835370 100644 --- a/src/android/BackgroundModeExt.java +++ b/src/android/BackgroundModeExt.java @@ -166,7 +166,18 @@ public void run() { try { Thread.sleep(1000); getApp().runOnUiThread(() -> { - View view = webView.getEngine().getView(); + + View view = null; + + try{ + + view = webView.getEngine().getView(); + + }catch(Exception e){ + + view = webView.getView(); + + } try { Class.forName("org.crosswalk.engine.XWalkCordovaView")