Flutter application restart instead of resuming after some time when switch to other applications - flutter

Hi i am developing a flutter application and i am using getx statemanagment. The problem is when i put application in background and use some other applications like whatsapp,youtube,play a game or listen music, after some time when i resume my application from recents it restarts and all progress is lost.
I have already tried different solutions like moveTaskToback(true) with native android function call
Please help, I have almost finished my important application.

I'm not sure on why this happens, but some manufacturers have their own restrictions on apps running in the background. Nothing you can really do from a flutter perspective, the app lifecycle is the same on all devices.
Here is a link where they share some tips how to deal with this on Xiaomi from the users perspective.
https://dontkillmyapp.com/xiaomi
From the developers perspective, as you can read on the bottom of the article, the are no common workarounds known yet.

Related

Flutter Basics (write once, run anywhere?)

Hi stack overflow community,
I'm a novice programmer in high school and have never written an app for mobile devices before so please bear with me. If I was to write an app using Flutter, will I only be required to write the code once and then be able to distribute different versions of it (iOS, macOS, Windows, Linux, Android, etc)? Or will I need to make small changes for each version such as using XCode to create the iOS version and Android Studio for the Android version? I know this is such a basic question but I've spent a couple of hours looking this stuff up and I'm still confused. Any help would be nice.
Thanks,
Daniel
In a product development environment, after writing the cross-platform code with Flutter, there are some need-to-do tasks related to Native environment.
In the case of Android, there are several cases when you'll need to touch the Native level such as config Firestore settings, Social authentication (Login with Facebook for example), changing the launch icons/ splash screen of the app or publishing to app store, etc
For iOS, the same case apply as well. So I suggest you start with small steps to develop the app first, then when running into something that seems impossible with just Flutter code, there are tutorials and SO to guide you through. It might seem overwhelmed at first, but we are all on a journey, so no need to rush it ;)
You should make small changes too. For eg when adding launcher icons and splash screen you have to edit the respective native folders. When distributing for ios you need to manually customize its Runner from xcode. There are many library that support either android only or ios only. In that case if you need that feature you have to make changes in native code like java ans swift.
if you're creating your own native plugins, you will have unique code to write. But if you're just using things out of pub, almost nothing will require change (unless you are publishing to the store).

Flutter, Detecting that other apps are launched

I'm trying to develop an app that prevents a user from starting other application when my app is running. The scenario:
my app starts the timer
app detects launch of another app (could be anything other than my app)
if it detects, it cancels some achievements
Can anyone help? I saw some solutions on this topic, but could not find anything in Flutter.
Any ideas would help.
Thank you.
There is a few ways to do that but easy one to observe your app situation, you can use WidgetsBindingObserver to detect your app is background or not.
But if the case is not being background it is just depending to launch an app so there is a few ways which suggest in this answer you can try them.

Flutter : Run an app as a background service

I want to show a custom popup message whenever the user disconnects a cellular call. The problem is how to detect when the app is not running. any leads would be helpful.
It's been a while and there have been many developments.
First, there are some answers at How to create a service in Flutter to make an app to run always in background?
Also, flutter/Background processes will basically point you to medium/Executing Dart in the Background with Flutter Plugins and Geofencing (Sept 2018)
which is a Geofencing sample that involves a partnership between isolates, native Android/iOS code via MethodChannel, and PluginUtilities.getCallbackHandle (PluginUtilities)
Alas, there are many plugins available now:
https://pub.dev/packages/background_location
https://pub.dev/packages/android_alarm_manager (Android)
https://pub.dev/packages/background_fetch
https://pub.dev/packages/workmanager
https://pub.dev/packages/audio_service

can you install an iphone app with an invisible icon?

So I am working on a bundle of applications for my company for the iPad and am trying to figure out if it is possible to install an app but hide the icon. It will not need to be launched from the desktop directly. Instead, I have created a launch desktop that controls login and the launch of the actual apps via custom URL schemes. We decided to do this so we can have many people developing different apps at the time time that quickly and easily connect to a single login and launch desktop. We are trying to make all of the services we offer interconnected.
Does anyone know if this is possible? Or am I going to have to redirect to the login app if the user launches any of the individual apps. That is what we were trying to avoid. It would be incredibly annoying and clunky for the user. Any help would be greatly appreciated! Thanks!
No is the short answer, you can't install an app and hide the icon.
Even if you could, your architecture sounds pretty clunky. If your services are interconnected, then would it not be better to have everything in the same app? There are plenty of ways to share coding between many developers without everyone having their own, separate app.
Maybe.
There used to be a trick where if you installed so many apps that you filled up every page, any apps installed after that would not have a visible icon (but you could run them via a Spotlight search).
If this behavior still exists, then fill up your iPad's launcher/springboard with apps (download 100's of free games, etc.), then install the apps that you want to be invisible, then delete all the games, and your chosen app might remain with an "invisible" icon.

Create a mobile app that listens to incoming phone call events

As the title suggests, I would like to create a mobile app that runs in the background and catches "incoming call" events. Moreover I would like to use a Cross-Platform Development Tool to do this.
I looked at three tools: PhoneGap, Rhomobile and Appcelerator. But I couldn't find any documentation or examples that suggest they support such events.
It seems like the iPhone (correct me if I'm wrong) does not support this but Android and Blackberry do.
Did I miss something when I looked at the above mentioned tools and platforms?
Are there any other well established Cross-Platform Mobile Tools that could solve my problem?
Keeping the cross-platform support in mind, what approach would you follow to develop such an app?
On the iPhone, there's nothing you can do to "catch" or even register incoming calls. The only thing you could do is create an app that protocols the time at which it has been sent to the background or became inactive, because you'r appdelegate will be notified - but that will happen on many occasions, not only when a phone call is received. It won't work while the app is in the background (on multitasking enabled devices) alltogether. So, an app like this would be totally useless...
Sorry, no help there!