I am new to Flutter. Can anyone post the link or code for "android foreground service example with a notification"? I googled but didn't get any good example of foreground service.
I'm working on a project that includes an SMS package. This App has to be active on the foreground.
Update:
I have created my own implementation of android foreground service for Flutter called android_long_task. check it out it solved my problem. let me know if it solves your problem by raising an issue.I created my own library because the tutorial I mentioned just shows how to create a foreground service in java and that's all and as you have found out by now the other foregorund_service plugins have some problems.
Old answer (didn't help me):
if you're having a problem with this and none of the libraries mentioned in other answers worked for you. you might wanna give this tutorial from RetroPortal Studio a try. it's a total of 26 minutes which teaches you how to write a working foreground service for flutter android
I tried flutter_foreground_service but it has a big problem. When app closes this plugin throwing error. This bug is reported in here: https://github.com/pauldemarco/foreground_service/issues/1
foreground_service has problem too: https://github.com/pauldemarco/foreground_service/issues/1
Probably there isn't a good solution for now (Jan 2020). If someone develops a good solution may be I add it to here.
I think Google should find solution for this kind of problems. We're using flutter becouse we're thinking that flutter is more effective. If we lost our time kind of this absurd errors why we using flutter? Using kotlin for android, swift for ios this is more good probably.
Pauldemarco has created some excellent flutter packages for flutter. He has developed one for Foreground service too. As of now, it is only supported in android. It is not supported for iOS. I hope this helps.
https://github.com/pauldemarco/foreground_service
You can use library flutter_foreground_task for long or always running task.
Related
We are using Cordova 5.0.0 and its cordova-camera-plugin
When we are testing it on Android, the app crashes when the user takes a photo.
Looking at the links below, it seems that our app is being killed while the camera app it on front.
PhoneGap camera restarts the application
https://github.com/shaithana/cordova-plugin-wezka-nativecamera
While there are some answers but it seems to be outdated: The foreground camera plugin is not suitable to newer devices or Cordova and other solutions didn't work for us
Does anyone have an up-to-date solution?
Try to use this forked cordova-android and cordova-plugin-camera.
The docs, sample and discussion on the approach used can be found in the cordova-android PR.
BTW, the PRs are going to be merged soon.
First question that comes to my mind is: Why using this camera plugin: https://github.com/shaithana/cordova-plugin-wezka-nativecamera
It's obviously a fork. You might have a good reason for that. It's also outdated. Last contribution was one year ago.
Maybe you want to give the "official" plugin a shot:
https://github.com/apache/cordova-plugin-camera
Going deeper into detail without knowing more about your testing environment (which device(s) with which Android version) and without having possibility to review entire related code, is not possible and answers may not give any reliable advice for change.
Have you ensured, that the call to the camera plugin cannot happen before "deviceready" was triggered? Is cordova.js loaded?
Update:
You may also want to switch from raw alerts to console output. I recognized several times that alerts in callbacks triggered from plugins could cause some trouble.
As a general rule of thumb: Use console.log() instead of alert() and connect with Chrome (chrome://inspect) to the emulator or device to see what happens. You can additionally use adb logcat to have a look into the device log.
I've ran into a problem with apache cordova background modes. I need to make an application where my battery level is checked from time to time in the background (if the app is in background), and if it is below some level, then the app should notify you about it. Eventually I've managed to run it on android, with katzer's plugin, it does work indeed, but after a while it shuts down completely and on iOS it does not even work. I've tried other plugins but nothing was helpful. Can you please help me find the problem with this? Also it must work on wp8/8.1 that's why katzer's plugin suited me best. (Not to misunderstand me, it is an outstanding plugin, in fact the only that works).
Here is the code on Pastebin
Also I'm linking the plugin which I'm using at the moment
Thanks in advance
I've recently started android programming, and I'm extremely frustrated to say the least with a lot of things that to me seem simple but are totally holding me back from making any progress. The first of which is the "my first app" hello world that I started a tutorial from http://developer.android.com/training/basics/firstapp/creating-project.html
This tutorial worked fine when I was originally looking into android a while ago. Then when I came back after learning a bunch of java this program will no longer work unless I change the target-sdk to version 10 (I found that solution after extensive searching on this site).
Then I moved on to starting tutorials by thenewboston
All of these work fine as long as I didn't use any new targetsdkversion, so I'm wondering what happened that everywhere I go looking for tutorials I can't find anything that will actually work on the current ADT(4.4W and L are what my eclipse automatically set up) and eclipse (indigo). I'll also get issues saying lint isn't working, or trouble with android SDK content loader when I'm not even doing anything.
I've also found snippets of code example on the developer website that I linked earlier that don't work when implemented either
So, am I missing something, is that just old documentation, or is something up with eclipse and ADT? I'm just so frustrated that everything wants to bug out on me when I'm just trying to follow simple introductory tutorials and I don't even know where to turn for tutorials that I can trust to work..
edit:removed code because it wasn't needed.
To not get blocked What you can do is continue to set "targetVersion as '19'" instead of setting it to 20 or so. Ensure that you've downloaded API19 through SDK Manager and create the AVDs with that targetSDK version for checking you apps.
That way you can proceed ahead with your coding and later when things get resolved by google for API20...you can always comeback to that new version. This way you can follow 'TheNewBoston' and start coding in Android.
I also recommend 'Slidenerd' tutorials over youtube as well for the beginner.
BTW, I've also selected 'Blank Activity / Empty Activity" during the project creation with API19 and been able to move ahead with my coding.
The Google Bug thread about this latest version issue can be tracked here : The google bug
As a beginning developer, I suggest you use API 19. It has been out for a while and is more stable than L or Google Wear.
I have an application that uses a native library (.so).
In the new version of the application I made changes in the lib. The problem is that after upgrading the application it looks like the new library is not loaded.
If I force stop the application and then I restarted it everything works fine.
In some cases just waiting for a while (for example 20 mins) fixes the problem.
Did anyone experience this issue?
Is there a way to fix it?
EDIT
I have also tried to call
System.loadLibrary("mylib.so");
in the onReceive of the OnUpgradeReceiver that is the broadcast receiver that is registered to be called when the application is upgraded
It did not help
EDIT2
I think this issue has to do with the fact that the lib uses the audio engine. The reason iwhy I think so is that I tried to change the name of the lib and it did not help either
Ok never mind I think the issue is just in my lib. I need to find where but I checked that the application is properly closed after the upgrading.
recently, I've started the developing of a new app, and this app is in need of constant update. I know I can do it with alarms, but I think that a better way is to add my app to android automatic sync service (the one that is added gmail app and whatsapp for example).
I've looked for that topic, but couldn't find any answer about how to interact with that service. Can anybody provide me an example of how to accomplish it?
Thank you so much,
Vyrphan
Check out the SampleSyncAdapter code under the SDK samples. It will be in a directory akin to;
C:/Program
Files/Android/android-sdk/samples/android-10/SampleSyncAdapter/
Maybe this can help you http://developer.android.com/training/cloudsync/index.html