async_wallpaper icon indicating copy to clipboard operation
async_wallpaper copied to clipboard

Invoking setWallpaper inside workmanager yields PlaformException

Open innomatica opened this issue 3 years ago • 2 comments

I want to change the wallpaper in the background at a certain point. WorkManager invokes

AsyncWallpaper.setWallpaperFromFile(localFilePath);

and creates following PlatformException

E/MethodChannel#async_wallpaper(14385): Failed to handle method call
E/MethodChannel#async_wallpaper(14385): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.startActivity(android.content.Intent)' on a null object reference
E/MethodChannel#async_wallpaper(14385): 	at com.codenameakshay.async_wallpaper.AsyncWallpaperPlugin.home(AsyncWallpaperPlugin.java:158)
E/MethodChannel#async_wallpaper(14385): 	at com.codenameakshay.async_wallpaper.AsyncWallpaperPlugin.onMethodCall(AsyncWallpaperPlugin.java:210)
E/MethodChannel#async_wallpaper(14385): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#async_wallpaper(14385): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#async_wallpaper(14385): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#async_wallpaper(14385): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#async_wallpaper(14385): 	at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#async_wallpaper(14385): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#async_wallpaper(14385): 	at android.os.Looper.loopOnce(Looper.java:201)
E/MethodChannel#async_wallpaper(14385): 	at android.os.Looper.loop(Looper.java:288)
E/MethodChannel#async_wallpaper(14385): 	at android.app.ActivityThread.main(ActivityThread.java:7839)
E/MethodChannel#async_wallpaper(14385): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#async_wallpaper(14385): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/MethodChannel#async_wallpaper(14385): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Any suggestion would be appreciated.

TIA,

Flutter:

  • version: 3.3.9
  • channel: stable

Dart:

  • version: 2.18.5

innomatica avatar Nov 24 '22 14:11 innomatica

Did you ever get this working?

jjfster avatar Dec 28 '23 01:12 jjfster

No I didn't.

innomatica avatar Dec 28 '23 13:12 innomatica