GithubHelp home page GithubHelp logo

easazade / android_long_task Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 7.0 167 KB

android long task is a flutter plugin to run dart code in an android foreground service with simplicity

License: Apache License 2.0

Kotlin 44.17% Swift 3.32% Objective-C 2.66% Dart 41.37% Ruby 8.47%
flutter foreground-service background-service background android dart service

android_long_task's Introduction

πŸ‘‹ Β  Hello Github! I am Ali.

blog Β  linkedin Β  linkedin Β  instagram Β  twitter Β  youtube Β  telegram

  • πŸ“± I’m a Mobile Developer experienced in Flutter and Native Android
  • ❀️‍πŸ”₯ I'm passionate about creating tools and libraries that make the development process easier/faster while also achieving a maintainable, testable, reliable result.
  • 😎 I've worked with Java, Kotlin, Dart and Played with PHP, Python, JavaScript.
  • ✌ Right now I'm interested in contributing to open source projects that improve dart's place in other areas of programming like web (backend/frontend). So I'm Contributing to jaspr and dart_frog.
  • πŸ’» besides creating tools, I love creating beautiful Apps. If you have an application project with GREATπŸ‘Œ or Challenging ui design contact me.
  • πŸ“­ You can email me at [email protected]. ( I might be slow to answer )

Github Page Stars Pub Likes popularity Contributors πŸ‘‘ Version
android_long_task Github Stars Pub Likes Pub Popularity GitHub contributors easazade Pub Version
fantom Github Stars Pub Likes Pub Popularity GitHub contributors rekabhq Pub Version
faker_x Github Stars Pub Likes Pub Popularity GitHub contributors easazade Pub Version
font_preview Github Stars Pub Likes Pub Popularity GitHub contributors easazade Pub Version
crystalline Github Stars Pub Likes Pub Popularity GitHub contributors easazade Pub Version

android_long_task's People

Contributors

easazade avatar eimji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

android_long_task's Issues

Service notification not visible on Android 13(API level 33)

Hi, thanks for your great service. I have been used it on 2 applications already and now planning on 3th one :) .
While developing a POC on the 3th one noticed that the notification for the service is not visible on the Pixel 6 phone that runs on android 13. Quick check in the documentation shows that there are some new restrictions :
https://developer.android.com/guide/components/foreground-services#notification-immediate

I think a quick fix will be to add a button on the notification that should show the notification. Maybe that button could be to stop the service, which will be great user experience(if we can handle that click on flutter side, do our final work and stop the service).

For now my quick solution is to build against API 32, in that case shows the notification even on the PIxel

With flutter 2.2.3 your example doen't work

I'm trying to run your example with flutter 2.2.3 and I'm getting this error message:E/flutter ( 7230): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: type 'Null' is not a subtype of type 'Map<String, dynamic>'
E/flutter ( 7230): #0 AppClient.getData (package:android_long_task/long_task/app_client.dart:49:26)
E/flutter ( 7230):

My flutter doctor output is:
[βœ“] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en-IT)
[βœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[βœ“] Xcode - develop for iOS and macOS
[βœ“] Chrome - develop for the web
[βœ“] Android Studio (version 4.2)
[βœ“] Connected device (2 available)

β€’ No issues found!

Best
Alex

serviceMain stops when the device screen is off

serviceMain does not close but stops when the device screen is off, once you turn on the screen, the service continues to run without problems. I need the service to keep running when the screen is off. How can I achieve this?

Stop service when app killed

How to stop the service when app is killed or exited? I successfully initialized the service, it's working fine when I minimize app. But it still working when I exit app and I want to stop it when I exit the app. Please help me.

Using flutter_blue together with android-long-task leads to a PlatformException

Hey @easazade ,

I'm trying to use your package to download files from a BLE device in the background. It runs fine so far. However, I receive the following exception when I try to run any function from flutter_blue https://pub.dev/packages/flutter_blue

As soon as I try to run my initialization function for the BLEManager

Future<bool> asyncInit() async {
   flutterBlue = FlutterBlue.instance;
   await flutterBlue.stopScan();
   for (var device in await flutterBlue.connectedDevices) {
     await device.disconnect();
   }
   return true;
 }

I get the following exception:

E/flutter (11319): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: MissingPluginException(No implementation found for method isAvailable on channel plugins.pauldemarco.com/flutter_blue/methods)
E/flutter (11319): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7)
E/flutter (11319):
E/flutter (11319): #.1 FlutterBlue._setLogLevelIfAvailable (package:flutter_blue/src/flutter_blue.dart:78:9)
E/flutter (11319):
E/flutter (11319):

Any idea what's going wrong?

best regards and thanks for the nice plugin!

Detect the service is started

In general we can use AppClient.getData() from the app and see latest status.
Is it possible to query the AppClient and check if the service is running?

The problem is that if the code in the service callback has a problem and can not complete correct and update the status, then every time when you check from the app you will have a status that indicates running process.

For example if we have 3 statuses (UploadImages, UploadingImages and Idle). We want to start our service and upload the images only if current status is Idle. Then we send UploadImages to our service, the service starts uploading and changes it's status to UploadingImages. At this time there could be a problem and the service may stop here, then next time when you getData from the service will receive UploadingImages. Currently this status will remain until the app is force stopped and started again, then we will have null as response.

I'm surrounding my code with try catch and trying to close the service properly if something unpredictable happens, but still if is possible from the AppClient to check if the service is running will be great

Dart Unhandled Exception: NoSuchMethodError: No top-level getter 'serviceMain' declared.

Hello

Running the example with flutter run --release gives this error

E/flutter (14495): [ERROR:flutter/shell/common/shell.cc(94)] Dart Unhandled Exception: NoSuchMethodError: No top-level getter 'serviceMain' declared.
E/flutter (14495): Receiver: top-level
E/flutter (14495): Tried calling: serviceMain, stack trace: #0      NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:218)
E/flutter (14495): 
E/flutter (14495): [ERROR:flutter/runtime/dart_isolate.cc(707)] Could not resolve main entrypoint function.
E/flutter (14495): [ERROR:flutter/runtime/dart_isolate.cc(191)] Could not run the run main Dart entrypoint.
E/flutter (14495): [ERROR:flutter/runtime/runtime_controller.cc(382)] Could not create root isolate.
E/flutter (14495): [ERROR:flutter/shell/common/shell.cc(574)] Could not launch engine with configuration.

The code only works in debug mode.
This is very weird, the code worked well a few weeks ago. It seems to be an issue related to Flutter
flutter/flutter#91841
I don't know how to fix the issue, which is a severe regression.

Could you confirm the issue please? and help me to find a workaround.

Thanks

Flutter 3.13.9 Old Kotlin version breaks build process

Hi,

i received the following error in my Flutter 3.13.9 project:

The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
The following dependencies do not satisfy the required version:
project ':android_long_task' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

I fixed the Error by adjusting the Kotlin Version. I will submit a PR :).
In the meantime, if anyone suffers from this error, you might be able to get around this by using the following in your pubspec.yaml file:

  android_long_task:
    git:
      url: 'https://github.com/robinduerhager/android_long_task.git'
      ref: '3f90808ff72e6bead9b77de4655f9439c4b82482'

Add autostart?

I'm looking at your project to see if it can replace the unreliable WorkManager/AlarmManager for me.

One of the things I need is that my foreground service will be started automatically on a device reboot, or if the foreground service is stopped for any reason other than explicit user command.

I'm afraid I have have no idea where to start with these. Roberto has some suggestions in a similar project he wrote up at https://robertohuertas.com/2019/06/29/android_foreground_services/ (at "Bonus" and "Bonus 2" but his code seems totally different to your own.

How might I go about adding that functionally to your project?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.