Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Indoor location app is crashing while running #12

Open
FabinMVarghese opened this issue Feb 2, 2018 · 1 comment
Open

Indoor location app is crashing while running #12

FabinMVarghese opened this issue Feb 2, 2018 · 1 comment

Comments

@FabinMVarghese
Copy link

Prerequisites

  • [X ] Put an X between the brackets on this line if you have done all of the following:
    • My beacons have Estimote Location packet enabled (Check it in the Estimote Cloud, or via app)
    • My Android device/devices supports BLE and has Android OS version >= 5.0.0
    • My Android device/devices have bluetooth enabled
    • My app has Location Permissions granted

Basic information

Estimote SDK version: [indoorsdk:2.0.1]

Android devices affected: [Redmi Note $]

Android OS version affected: [Android OS version (Nougat 7.0.0)]

Beacon hardware version: [F3.3]

Description

[My Indoor Location app is crashing while running. I want to pass location Id and display the location according to the location id.]

Steps to reproduce:

  1. [I have changed App ID and App token]
  2. [I have my location name]
  3. [and so on...]

Expected behavior: [ My current indoor location]

Actual behavior: [ App is crashing without loading anything]

(Optional) Additional information

Add here any logs you want to attach, or any other info, like pictures for example

I am copying my code below.

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.estimote.cloud_plugin.common.EstimoteCloudCredentials;
import com.estimote.indoorsdk.IndoorLocationManagerBuilder;
import com.estimote.indoorsdk_module.algorithm.IndoorLocationManager;
import com.estimote.indoorsdk_module.algorithm.OnPositionUpdateListener;
import com.estimote.indoorsdk_module.algorithm.ScanningIndoorLocationManager;
import com.estimote.indoorsdk_module.cloud.CloudCallback;
import com.estimote.indoorsdk_module.cloud.EstimoteCloudException;
import com.estimote.indoorsdk_module.cloud.IndoorCloudManager;
import com.estimote.indoorsdk_module.cloud.IndoorCloudManagerFactory;
import com.estimote.indoorsdk_module.cloud.Location;
import com.estimote.indoorsdk_module.cloud.LocationPosition;
import com.estimote.indoorsdk_module.view.IndoorLocationView;

public class MainActivity extends AppCompatActivity {
public IndoorLocationManager indoorLocationManager;
public Location location;
IndoorLocationView indoorView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    IndoorCloudManager cloudManager = new IndoorCloudManagerFactory().create(getApplicationContext(), new EstimoteCloudCredentials("YOUR-APP-ID", "YOUR-APP-TOKEN"));
    cloudManager.getLocation("my-kitchen", new CloudCallback<Location>() {
        @Override
        public void success(Location location) {
            // store the Location object for later,
            // you will need it to initialize the IndoorLocationManager!
            //
            // you can also pass it to IndoorLocationView to display a map:
            indoorView = (IndoorLocationView) findViewById(R.id.indoor_view);
             indoorView.setLocation(location);
        }

        @Override
        public void failure(EstimoteCloudException e) {
            // oops!
        }
    });
    ScanningIndoorLocationManager indoorLocationManager =
            new IndoorLocationManagerBuilder(this, location, new EstimoteCloudCredentials("indoorappone-iaa", "29351fc19660c463a1a813d6271bdd8d"))
                    .withDefaultScanner()
                    .build();
    indoorLocationManager.setOnPositionUpdateListener(new OnPositionUpdateListener() {
        @Override
        public void onPositionUpdate(LocationPosition position) {
            // here, we update the IndoorLocationView with the current position,
            // but you can use the position for anything you want
            indoorView.updatePosition(position);
        }

        @Override
        public void onPositionOutsideLocation() {
            indoorView.hidePosition();
        }
    });

}
@Override
protected void onStart() {
    super.onStart();
    indoorLocationManager.startPositioning();
}

@Override
protected void onStop() {
    super.onStop();
    indoorLocationManager.stopPositioning();
}

}

@FabinMVarghese
Copy link
Author

I am getting the following errors.

02-03 16:12:32.540 2043-2043/com.sangamone.indoorlocation.indoordemo4 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sangamone.indoorlocation.indoordemo4, PID: 2043
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sangamone.indoorlocation.indoordemo4/com.sangamone.indoorlocation.indoordemo4.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.estimote.indoorsdk_module.algorithm.ScanningIndoorLocationManager.startPositioning()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2785)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1532)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.estimote.indoorsdk_module.algorithm.ScanningIndoorLocationManager.startPositioning()' on a null object reference
at com.sangamone.indoorlocation.indoordemo4.MainActivity.onStart(MainActivity.java:78)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1249)
at android.app.Activity.performStart(Activity.java:6873)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2687)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2785) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1532) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:163) 
at android.app.ActivityThread.main(ActivityThread.java:6342) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770) 

Following is my updated code,

package com.sangamone.indoorlocation.indoordemo4;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.estimote.indoorsdk.IndoorLocationManagerBuilder;
import com.estimote.indoorsdk_module.algorithm.OnPositionUpdateListener;
import com.estimote.indoorsdk_module.algorithm.ScanningIndoorLocationManager;
import com.estimote.indoorsdk_module.cloud.CloudCallback;
import com.estimote.indoorsdk_module.cloud.EstimoteCloudException;
import com.estimote.indoorsdk_module.cloud.IndoorCloudManager;
import com.estimote.indoorsdk_module.cloud.IndoorCloudManagerFactory;
import com.estimote.indoorsdk_module.cloud.Location;
import com.estimote.indoorsdk_module.cloud.LocationPosition;
import com.estimote.indoorsdk_module.view.IndoorLocationView;
import com.estimote.internal_plugins_api.cloud.CloudCredentials;
import com.estimote.cloud_plugin.common.EstimoteCloudCredentials;

public class MainActivity extends AppCompatActivity {

IndoorLocationView indoorLocationView;
Location loc;
ScanningIndoorLocationManager indoorLocationManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    indoorLocationView = (IndoorLocationView) findViewById(R.id.indoor_view);
    //indoorLocationView.setLocation(location);

    final CloudCredentials cloudCredentials = new EstimoteCloudCredentials("sangamoneindoor-jsm", "8c2be70b812ee53f08b6dd9a965cf010");
    IndoorCloudManager cloudManager = new IndoorCloudManagerFactory().create(this, cloudCredentials);
    cloudManager.getLocation("location2-9wk", new CloudCallback<Location>() {
        @Override
        public void success(Location location) {
            // do something with your Location object here.
            // You will need it to initialise IndoorLocationManager!
            indoorLocationView = (IndoorLocationView) findViewById(R.id.indoor_view);
            indoorLocationView.setLocation(location);
            loc = location;

            Log.d("locationlocation", "" + location);
            indoorLocationManager =
                    new IndoorLocationManagerBuilder(getApplicationContext(), location, cloudCredentials)
                            .withDefaultScanner()
                            .build();

            indoorLocationManager.setOnPositionUpdateListener(new OnPositionUpdateListener() {
                @Override
                public void onPositionUpdate(LocationPosition locationPosition) {
                    indoorLocationView.updatePosition(locationPosition);
                }

                @Override
                public void onPositionOutsideLocation() {


                    indoorLocationView.hidePosition();
                }
            });
        }

        @Override
        public void failure(EstimoteCloudException e) {
            // oops!
        }
    });


}

@Override
protected void onStart() {
    super.onStart();
    indoorLocationManager.startPositioning();

}

@Override
protected void onStop() {
    super.onStop();

}

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant