Giter VIP home page Giter VIP logo

gps_connectivity's Introduction

gps_connectivity

A Flutter plugin that checks whether GPS is ON or OFF, it can listen for GPS change. Inspired by connectivity_plus plugin

Platform Support

Only Android for now.

Usage

Sample usage to check current GPS status:

import 'package:gps_connectivity/gps_connectivity.dart';

bool isGpsEnabled = await (GpsConnectivity().checkGpsConnectivity());
if (isGpsEnabled) {
  // GPS is ON.
} else {
  // GPS is OFF.
}

You can also listen for GPS state changes by subscribing to the stream exposed by plugin:

import 'package:gps_connectivity/gps_connectivity.dart';

@override
initState() {
  super.initState();

  subscription = GpsConnectivity().onGpsConnectivityChanged.listen((bool result) {
    // Got a new GPS status!
  });
}

// Be sure to cancel subscription after you are done
@override
dispose() {
  subscription.cancel();
  super.dispose();
}

gps_connectivity's People

Contributors

khamidjon avatar

Stargazers

 avatar Chihiro avatar  avatar Jim,czj avatar Andres Garcia avatar Azamat Makhkamov avatar

Watchers

 avatar

gps_connectivity's Issues

One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts, null, null)

I'm getting the following exception after jumping forward to Android SDK 34:

======== Exception caught by services library ======================================================
The following PlatformException was thrown while activating platform stream on channel uz.thunder.gps_connectivity/gps_connectivity_status:
PlatformException(error, my.example.project: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts, null, null)

Android Crash on Killing the Application

android_background_crash.txt
On killing android application, the code on android teardown tries to stop the GPS Listener and it causes error as argument passed is null. Listener was not started yet.

Please find the logs attached

at uz.thunder.gps_connectivity.GpsConnectivityBroadcastReceiver.onCancel(GpsConnectivityBroadcastReceiver.java:2)
at uz.thunder.gps_connectivity.GpsConnectivityPlugin.teardownChannels(GpsConnectivityPlugin.java:22)
[android_background_crash.txt](https://github.com/khamidjon/gps_connectivity/files/11075952/android_background_crash.txt)
at uz.thunder.gps_connectivity.GpsConnectivityPlugin.onDetachedFromEngine(GpsConnectivityPlugin.java:5)

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.