0

In my NativeScript app I need to get additional geolocation info like satellite count or satellite ids which isn't provided by nativescript-geolocation plugin.

I am trying to use GnssStatus class from android.location in NativeScript app with the following:

const gnssCb = new android.location.GnssStatus.Callback();

After that I get an error:

ERROR Error: JNI Exception occurred (SIGABRT)

What am I doing wrong? Or is there any alternative way I can get that info?

4
  • I guess you are missing the onSatelliteStatusChanged method implementation, try adding that. Commented Jan 28, 2020 at 4:25
  • @Manoj it would be great if you could provide a code snippet how to do this in NativeScript Commented Jan 28, 2020 at 9:38
  • Try new android.location.GnssStatus.Callback({onSatelliteStatusChanged: function(status){}}); Commented Jan 28, 2020 at 16:10
  • Thanks for this snippet :). Unfortunately it didn't work for me: cannot marshal javascript argument object object at index 0 to java type Commented Jan 29, 2020 at 13:34

1 Answer 1

1

android.location.GnssStatus.Callback is a class inherited from Object, so you may have to extend it to override the methods. I tested below code with Playground, it executes as expected.

class MyGnssStatus extends android.location.GnssStatus.Callback {
    constructor() {
      super();
      return global.__native(this);
    }

    onSatelliteStatusChanged(status) {

    }
  }
Sign up to request clarification or add additional context in comments.

1 Comment

Looks good. Thanks for your answer! Not tested it yet. Will come back to this task soon to will leave the feedback here.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.