I want to display a msg box when another app is launched. The msg can be changed in a Flutter app. So this last one got to be responsible for displaying. It would run in the background. Any ideas?
This is part of a learning experience for Flutter. So, so far the technologies that was tried is basic Flutter
Flutter uses a different rendering canvas as compared to what native apps use. I don't think it is possible to display a message box or AlertDialog using Flutter's own rendering on top of another app. The only way I see in order to do this is implementing a platform-specific functionality.
For Android, you can use a BroadcastReceiver to check the app that have been launched. More info here.
Related
I have notification which has buttons. On a button click I want to call an API and just patch its value.
Its something like Whatsapp reply where we don't want the app to launch.
I know we can write native code for android and ios seperately. But it would be really great if i could run a snippet of dart code.
Since you have only asked if you can, yes you can. We did it in our android app a while back. The whole point of flutter engine is not only to render UIs but also to run code inside it without any UIs as well. Use platform channels for communication.
I am using Flutter's share plugin to share contents from my app.
Share.share("A sample text that is shared")
Upon inspection, I found that the plugin invokes a method 'share'on the MethodChannel 'plugins.flutter.io/share'. This brings up a bottom sheet depending on the platform. What I would like to do is capture the closing of this share sheet. The share sheet can be closed by:
Clicking on the region outside the sheet
Pressing the back button on Android
Clicking one of the options in the sheet which then opens up the respective application
Ideally, the Future of this "share" would return the information which could be used to decide if the user aborted the share (cases 1 and 2) or proceeded along with the share(case 3). I am trying to do this to track the number of times a content is shared from my app.
The Share.share returns a Future<void> which I believe is resolved after the method is invoked on the platform channel.
Is there a way I can capture when the platform's share sheet closes just like we can capture when other widgets like dialogs are popped? Or more specifically,
Is there a way to know if the user actually proceeded with the share or not?
Something like this would have made it much easier:
Share.share("A sample text that is shared").then((bool isAborted) {
// Do something...
});
You have correctly figured out that this is not possible using the share plugin.
Additionally, this is also not possible on the platform level anyway (see an Android answer for reference).
Moreover, the answer to your request would be to create an issue at flutter/flutter because this is a plugin by the Flutter team and GitHub issues are used to track such feature requests. In this case, you want to make sure to include [share] in your issue title. See the flutter/plugins README for reference.
I am working in an application where I would like to combine a code that I have developed in Android with Flutter.
More specifically, I have a login in Android where I would like to send me to the main that I have in Flutter.
I would like to know if I can pass from an Android activity to Flutter as I normally do in Android with the manifest.
Does anyone know if this is possible?
Yes, you can.
You can use a Platform View to achieve what you want, in this particular scenario, an AndroidView widget. It’s more or less like a platform plugin, but this time, you’re actually inlining native views in your widget tree.
It’s not immediate and there are a few things that you need to setup before achieving it, so you should only do so if your activity is too complex to the point where it’s not worth to recreate and maintain with Flutter widgets.
Nevertheless, I’ll leave you with an article that goes through the process of creating the Android Platform View itself.
Is there a way in Cordova to clear the screen before the app goes into the recent activity list on Android?
I'm making a game where I don't want the user to be able to see the playfield during a pause. So I need to switch visuals or something before the app ends up in the recent activity list.
At the moment I'm listening for the 'pause' event from Cordova, but even if I render the canvas once more at this point (or even remove it entirely) this new state won't show on the recent app list and instead still shows the previous frame.
I've seen some banking apps have this behavior so it should be possible somehow.
PS: I'm using PIXI as framework but I assume that's of no concern here.
I finally found the solution via this blog post: https://medium.com/#lakshaydulani/hybrid-app-horror-hiding-the-screenshot-in-app-switcher-82c318a350bf
Apparently there is a Cordova plugin that does exactly what I need: https://github.com/devgeeks/PrivacyScreenPlugin
Just install and compile the app.. Sweet!
Let's consider this use case:
I have an already developed app in android and iOS which is out here for a while. I would like to implement a library/package in Flutter that could run on Android and iOS projects. Let's say I want to store some data in the flutter part, trigger some events, and so on. I might not want to show any screen from flutter just a logic part would be here. Is it currently possible to do something like that? Just to reduce the effort to implement it natively in iOS and Android