PLACE sensing

PLACE sensing

Hi,

I tried to extend the sample code in "context_sdk_1.7.0.522\Android\Samples\LocationSensingSample" with an extra contextType cfr. code below

private void startSensing() {
    try {
        mySensing.addContextTypeListener(ContextType.LOCATION, mGeoListener);
        mySensing.enableSensing(ContextType.LOCATION, null);

        mySensing.addContextTypeListener(ContextType.PLACE, mGeoListener);
        mySensing.enableSensing(ContextType.PLACE, null);

    } catch (ContextProviderException e) {
        Toast.makeText(getApplicationContext(), "Error enabling / adding listener to provider: " + e.getMessage(), Toast.LENGTH_LONG).show();                    
        Log.e(LOG_TAG, "Error enabling provider");
    }
}

When I press "start sensing" the app crashes cfr log below.

The crash dump states  "Root cause: State Provider not registered", what does this mean?

Best regards,

Johan

------------------------- log ----------------------------------

 

09-02 17:12:07.696  11332-11332/com.intel.samples.locationsensing I/com.intel.context.Sensing﹕ Context sensing enabled for: urn:x-intel:context:type:location:current
09-02 17:12:07.696  11332-11332/com.intel.samples.locationsensing I/com.intel.context.Sensing﹕ Adding Listener to: urn:x-intel:context:type:location:place
09-02 17:12:07.696  11332-11332/com.intel.samples.locationsensing I/StateManager﹕ Adding a listener for urn:x-intel:context:type:location:place
09-02 17:12:07.696  11332-11332/com.intel.samples.locationsensing D/com.intel.context.provider.d﹕ Trying to enable the provider: urn:x-intel:context:type:location:place
09-02 17:12:07.696  11332-11332/com.intel.samples.locationsensing E/com.intel.context.Sensing﹕ Error enabling sensing
09-02 17:12:07.696  11332-11332/com.intel.samples.locationsensing D/com.intel.context.Sensing﹕ Error enabling sensing of specified context type. Make sure the context provider is available in the system. Root cause: State Provider not registered
09-02 17:12:07.696  11332-11332/com.intel.samples.locationsensing D/AndroidRuntime﹕ Shutting down VM
09-02 17:12:07.696  11332-11332/com.intel.samples.locationsensing W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41780d88)
09-02 17:12:07.706  11332-11332/com.intel.samples.locationsensing E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.intel.samples.locationsensing, PID: 11332
    java.lang.IllegalArgumentException: Error enabling provider place
            at com.intel.context.Sensing.enableSensing(SourceFile:206)
            at com.intel.samples.locationsensing.LocationSampleActivity.startSensing(LocationSampleActivity.java:110)
            at com.intel.samples.locationsensing.LocationSampleActivity.access$200(LocationSampleActivity.java:20)
            at com.intel.samples.locationsensing.LocationSampleActivity$3.onClick(LocationSampleActivity.java:61)
            at android.view.View.performClick(View.java:4569)
            at android.view.View$PerformClick.run(View.java:18560)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5137)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)

 

 

 

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Avoid Enable Sensing for Cloud Providers

The error is caused by the call to  enableSensing with ContextType.PLACE. Cloud providers do not require sensing to be enabled on the device, only the listener to be added. The following modification in code will get past the error.

Additionally to enable place sensing, be sure to enable the cloud service scopes within the authorization init call (auth.init): context:geolocation:detailed, context:location:detailed, and context:post:location:detailed. The scopes required for Place sensing are described at https://software.intel.com/en-us/articles/sensing-context-states-datasheet#02cloudbasedcontext. Place sensing requires 14 days of historical data to be collected. However, the ContextSensingApiFlowSample application shows how to pre-populate data for testing in the trainWork and trainHome methods within the ContextSensingApiFlowSampleActivity.

 

Modifications:

private void startSensing() {
    try {
        mySensing.addContextTypeListener(ContextType.LOCATION, mGeoListener);
        mySensing.enableSensing(ContextType.LOCATION, null);
 
        mySensing.addContextTypeListener(ContextType.PLACE, mGeoListener);
        // mySensing.enableSensing(ContextType.PLACE, null);
 
    } catch (ContextProviderException e) {
        Toast.makeText(getApplicationContext(), "Error enabling / adding listener to provider: " + e.getMessage(), Toast.LENGTH_LONG).show();                    
        Log.e(LOG_TAG, "Error enabling provider");
    }
}

Leave a Comment

Please sign in to add a comment. Not a member? Join today