src/com/example/ant_simple_test/Activity_DisplayBase.java
//Handle the result, connecting to events on success or reporting failure to user.
Handle the result, connecting to events on success or reporting failure to user.
Handle the result connecting to events on success or reporting failure to user .
@Override
        public void onResultReceived(AntPlusBikeSpeedDistancePcc result, RequestAccessResult resultCode, DeviceState initialDeviceState)
        {
            showDataDisplay("Connecting...");
            switch(resultCode)
            {
                case SUCCESS:
                    antPcc = result;
                    tv_status.setText(result.getDeviceName() + ": " + initialDeviceState);
                    subscribeToHrEvents();
                    break;
                case CHANNEL_NOT_AVAILABLE:
                    Toast.makeText(Activity_DisplayBase.this, "Channel Not Available", Toast.LENGTH_SHORT).show();
                    tv_status.setText("Error. Do Menu->Reset.");
                    break;
                case ADAPTER_NOT_DETECTED:
                    Toast.makeText(Activity_DisplayBase.this, "ANT Adapter Not Available. Built-in ANT hardware or external adapter required.", Toast.LENGTH_SHORT).show();
                    tv_status.setText("Error. Do Menu->Reset.");
                    break;
                case BAD_PARAMS:
                    Toast.makeText(Activity_DisplayBase.this, "Bad request parameters.", Toast.LENGTH_SHORT).show();
                    tv_status.setText("Error. Do Menu->Reset.");
                    break;
                case OTHER_FAILURE:
                    Toast.makeText(Activity_DisplayBase.this, "RequestAccess failed. See logcat for details.", Toast.LENGTH_SHORT).show();
                    tv_status.setText("Error. Do Menu->Reset.");
                    break;
                case DEPENDENCY_NOT_INSTALLED:
                    tv_status.setText("Error. Do Menu->Reset.");
                    AlertDialog.Builder adlgBldr = new AlertDialog.Builder(Activity_DisplayBase.this);
                    adlgBldr.setTitle("Missing Dependency");
                    adlgBldr.setMessage("The required service\n\"" + AntPluginPcc.getMissingDependencyName() + "\"\n was not found. You need to install the ANT+ Plugins service or you may need to update your existing version if you already have it. Do you want to launch the Play Store to get it?");
                    adlgBldr.setCancelable(true);
                    adlgBldr.setPositiveButton("Go to Store", new OnClickListener()
                    {
                        @Override
                        public void onClick(DialogInterface dialog, int which)
                        {
                            Intent startStore = null;
                            startStore = new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" + AntPluginPcc.getMissingDependencyPackageName()));
                            startStore.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            Activity_DisplayBase.this.startActivity(startStore);
                        }
                    });
                    adlgBldr.setNegativeButton("Cancel", new OnClickListener()
                    {
                        @Override
                        public void onClick(DialogInterface dialog, int which)
                        {
                            dialog.dismiss();
                        }
                    });
                    final AlertDialog waitDialog = adlgBldr.create();
                    waitDialog.show();
                    break;
                case USER_CANCELLED:
                    tv_status.setText("Cancelled. Do Menu->Reset.");
                    break;
                case UNRECOGNIZED:
                    Toast.makeText(Activity_DisplayBase.this,
                        "Failed: UNRECOGNIZED. PluginLib Upgrade Required?",
                        Toast.LENGTH_SHORT).show();
                    tv_status.setText("Error. Do Menu->Reset.");
                    break;
                default:
                    Toast.makeText(Activity_DisplayBase.this, "Unrecognized result: " + resultCode, Toast.LENGTH_SHORT).show();
                    tv_status.setText("Error. Do Menu->Reset.");
                    break;
            }
        }
@ Override public void onResultReceived ( AntPlusBikeSpeedDistancePcc result , RequestAccessResult resultCode , DeviceState initialDeviceState ) { showDataDisplay ( "Connecting..." ) ; switch ( resultCode ) { case SUCCESS : antPcc = result ; tv_status . setText ( result . getDeviceName ( ) + ": " + initialDeviceState ) ; subscribeToHrEvents ( ) ; break ; case CHANNEL_NOT_AVAILABLE : Toast . makeText ( Activity_DisplayBase . this , "Channel Not Available" , Toast . LENGTH_SHORT ) . show ( ) ; tv_status . setText ( "Error. Do Menu->Reset." ) ; break ; case ADAPTER_NOT_DETECTED : Toast . makeText ( Activity_DisplayBase . this , "ANT Adapter Not Available. Built-in ANT hardware or external adapter required." , Toast . LENGTH_SHORT ) . show ( ) ; tv_status . setText ( "Error. Do Menu->Reset." ) ; break ; case BAD_PARAMS : Toast . makeText ( Activity_DisplayBase . this , "Bad request parameters." , Toast . LENGTH_SHORT ) . show ( ) ; tv_status . setText ( "Error. Do Menu->Reset." ) ; break ; case OTHER_FAILURE : Toast . makeText ( Activity_DisplayBase . this , "RequestAccess failed. See logcat for details." , Toast . LENGTH_SHORT ) . show ( ) ; tv_status . setText ( "Error. Do Menu->Reset." ) ; break ; case DEPENDENCY_NOT_INSTALLED : tv_status . setText ( "Error. Do Menu->Reset." ) ; AlertDialog . Builder adlgBldr = new AlertDialog . Builder ( Activity_DisplayBase . this ) ; adlgBldr . setTitle ( "Missing Dependency" ) ; adlgBldr . setMessage ( "The required service\n\"" + AntPluginPcc . getMissingDependencyName ( ) + "\"\n was not found. You need to install the ANT+ Plugins service or you may need to update your existing version if you already have it. Do you want to launch the Play Store to get it?" ) ; adlgBldr . setCancelable ( true ) ; adlgBldr . setPositiveButton ( "Go to Store" , new OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { Intent startStore = null ; startStore = new Intent ( Intent . ACTION_VIEW , Uri . parse ( "market://details?id=" + AntPluginPcc . getMissingDependencyPackageName ( ) ) ) ; startStore . addFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ) ; Activity_DisplayBase . this . startActivity ( startStore ) ; } } ) ; adlgBldr . setNegativeButton ( "Cancel" , new OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; } } ) ; final AlertDialog waitDialog = adlgBldr . create ( ) ; waitDialog . show ( ) ; break ; case USER_CANCELLED : tv_status . setText ( "Cancelled. Do Menu->Reset." ) ; break ; case UNRECOGNIZED : Toast . makeText ( Activity_DisplayBase . this , "Failed: UNRECOGNIZED. PluginLib Upgrade Required?" , Toast . LENGTH_SHORT ) . show ( ) ; tv_status . setText ( "Error. Do Menu->Reset." ) ; break ; default : Toast . makeText ( Activity_DisplayBase . this , "Unrecognized result: " + resultCode , Toast . LENGTH_SHORT ) . show ( ) ; tv_status . setText ( "Error. Do Menu->Reset." ) ; break ; } }
Handle the result, connecting to events on success or reporting failure to user.
Handle the result connecting to events on success or reporting failure to user .
//Note: Since we compose all the params ourself, we should never see this result