src/com/example/ant_simple_test/Activity_DisplayBase.java
/**
     * Switches the active view to the data display and subscribes to all the data events
     */
Switches the active view to the data display and subscribes to all the data events
Switches the active view to the data display and subscribes to all the data events
public void subscribeToHrEvents()
    {
    	antPcc.subscribeCalculatedSpeedEvent(new CalculatedSpeedReceiver(new BigDecimal(2.095))
        {
            @Override
            public void onNewCalculatedSpeed(final long estTimestamp,
                final EnumSet<EventFlag> eventFlags, final BigDecimal calculatedSpeed)
            {
                runOnUiThread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                    	Log.d(TAG, "calculatedSpeed : " + calculatedSpeed);
                        tv_value.setText(String.valueOf(calculatedSpeed));
                    }
                });
            }
        });
    	Log.d(TAG, "antPcc.isSpeedAndCadenceCombinedSensor()" + antPcc.isSpeedAndCadenceCombinedSensor());
    	if(antPcc.isSpeedAndCadenceCombinedSensor())
    	{
    		runOnUiThread(new Runnable()
            {
                @Override
                public void run()
                {
                	bcReleaseHandle = AntPlusBikeCadencePcc.requestAccess(
                        Activity_DisplayBase.this,
                        antPcc.getAntDeviceNumber(), 
                        0, 
                        true,
                        new IPluginAccessResultReceiver<AntPlusBikeCadencePcc>()
                        {
                            @Override
                            public void onResultReceived(AntPlusBikeCadencePcc result,
                                RequestAccessResult resultCode,
                                DeviceState initialDeviceStateCode)
                            {
                                switch (resultCode)
                                {
                                    case SUCCESS:
                                        bcPcc = result;
                                        bcPcc.subscribeCalculatedCadenceEvent(new ICalculatedCadenceReceiver()
                                            {
                                                @Override
                                                public void onNewCalculatedCadence(
                                                    long estTimestamp,
                                                    EnumSet<EventFlag> eventFlags,
                                                    final BigDecimal calculatedCadence)
                                                {
                                                    runOnUiThread(new Runnable()
                                                    {
                                                        @Override
                                                        public void run()
                                                        {
                                                        	Log.d(TAG, "calculatedCadence : " + calculatedCadence);
                                                            tv_value_2.setText(String.valueOf(calculatedCadence));
                                                        }
                                                    });
                                                }
                                            });
                                        break;
                                    case CHANNEL_NOT_AVAILABLE:
                                        break;
                                    case BAD_PARAMS:
                                        break;
                                    case OTHER_FAILURE:
                                        break;
                                    case DEPENDENCY_NOT_INSTALLED:
                                        break;
                                    default:
                                        break;
                                }
                            }
                        },
                        new IDeviceStateChangeReceiver()
                        {
                            @Override
                            public void onDeviceStateChange(final DeviceState newDeviceState)
                            {
                                runOnUiThread(new Runnable()
                                {
                                    @Override
                                    public void run()
                                    {
                                        Log.d(TAG, "onDeviceStateChange : " + newDeviceState);
                                    }
                                });
                            }
                        });
                }
            });
    	}
    }
public void subscribeToHrEvents ( ) { antPcc . subscribeCalculatedSpeedEvent ( new CalculatedSpeedReceiver ( new BigDecimal ( 2.095 ) ) { @ Override public void onNewCalculatedSpeed ( final long estTimestamp , final EnumSet < EventFlag > eventFlags , final BigDecimal calculatedSpeed ) { runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { Log . d ( TAG , "calculatedSpeed : " + calculatedSpeed ) ; tv_value . setText ( String . valueOf ( calculatedSpeed ) ) ; } } ) ; } } ) ; Log . d ( TAG , "antPcc.isSpeedAndCadenceCombinedSensor()" + antPcc . isSpeedAndCadenceCombinedSensor ( ) ) ; if ( antPcc . isSpeedAndCadenceCombinedSensor ( ) ) { runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { bcReleaseHandle = AntPlusBikeCadencePcc . requestAccess ( Activity_DisplayBase . this , antPcc . getAntDeviceNumber ( ) , 0 , true , new IPluginAccessResultReceiver < AntPlusBikeCadencePcc > ( ) { @ Override public void onResultReceived ( AntPlusBikeCadencePcc result , RequestAccessResult resultCode , DeviceState initialDeviceStateCode ) { switch ( resultCode ) { case SUCCESS : bcPcc = result ; bcPcc . subscribeCalculatedCadenceEvent ( new ICalculatedCadenceReceiver ( ) { @ Override public void onNewCalculatedCadence ( long estTimestamp , EnumSet < EventFlag > eventFlags , final BigDecimal calculatedCadence ) { runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { Log . d ( TAG , "calculatedCadence : " + calculatedCadence ) ; tv_value_2 . setText ( String . valueOf ( calculatedCadence ) ) ; } } ) ; } } ) ; break ; case CHANNEL_NOT_AVAILABLE : break ; case BAD_PARAMS : break ; case OTHER_FAILURE : break ; case DEPENDENCY_NOT_INSTALLED : break ; default : break ; } } } , new IDeviceStateChangeReceiver ( ) { @ Override public void onDeviceStateChange ( final DeviceState newDeviceState ) { runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { Log . d ( TAG , "onDeviceStateChange : " + newDeviceState ) ; } } ) ; } } ) ; } } ) ; } }
Switches the active view to the data display and subscribes to all the data events
Switches the active view to the data display and subscribes to all the data events
// 2.095m circumference = an average 700cx23mm road tire // Handle the result, connecting to events // on success or reporting failure to user. // Receives state changes and shows it on the // status display line