pichillilorenzo / flutter_appavailability

A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.
https://pub.dartlang.org/packages/flutter_appavailability
MIT License
92 stars 89 forks source link

Can't open my app from background #25

Open spacekestrel opened 3 years ago

spacekestrel commented 3 years ago

I am trying to implement alarm clock, using alarm manager and this package, but it gives me this message, when i trying to launch app from background:

E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): Failed to handle method call
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at com.pichillilorenzo.flutter_appavailability.AppAvailability.getAppPackageInfo(AppAvailability.java:93)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at com.pichillilorenzo.flutter_appavailability.AppAvailability.launchApp(AppAvailability.java:131)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at com.pichillilorenzo.flutter_appavailability.AppAvailability.onMethodCall(AppAvailability.java:57)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at android.os.Looper.loop(Looper.java:183)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at android.app.ActivityThread.main(ActivityThread.java:7656)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter ( 4567): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference
E/flutter ( 4567):  at com.pichillilorenzo.flutter_appavailability.AppAvailability.getAppPackageInfo(AppAvailability.java:93)
E/flutter ( 4567):  at com.pichillilorenzo.flutter_appavailability.AppAvailability.launchApp(AppAvailability.java:131)
E/flutter ( 4567):  at com.pichillilorenzo.flutter_appavailability.AppAvailability.onMethodCall(AppAvailability.java:57)
E/flutter ( 4567):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter ( 4567):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter ( 4567):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/flutter ( 4567):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 4567):  at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter ( 4567):  at android.os.Looper.loop(Looper.java:183)
E/flutter ( 4567):  at android.app.ActivityThread.main(ActivityThread.java:7656)