Skip to content

Instantly share code, notes, and snippets.

@divyanshub024
Last active September 8, 2019 09:51
Show Gist options
  • Save divyanshub024/dd6346a83612f9779ec21f0bac196546 to your computer and use it in GitHub Desktop.
Save divyanshub024/dd6346a83612f9779ec21f0bac196546 to your computer and use it in GitHub Desktop.
private const val CHANNEL = "com.divyanshu.chitr/wallpaper"
class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this)
MethodChannel(flutterView, CHANNEL).setMethodCallHandler { call, result ->
if (call.method == "setWallpaper") {
val arguments = call.arguments as ArrayList<*>
val setWallpaper = setWallpaper(arguments[0] as String, applicationContext, arguments[1] as Int)
if (setWallpaper == 0) {
result.success(setWallpaper)
} else {
result.error("UNAVAILABLE", "", null)
}
} else {
result.notImplemented()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment