Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Generics in Android

Rank

Total Posts: 12

Joined 2014-08-25

PM

Hi,



Is it possible to define a particular Callback(i.e. on Resultrecieved()) that will be called when we recieve the data irrespective of the profile ,?
how to create object dynamically for that particular profile?

     
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

I found the API forces you to implement each required IPluginAccessResultReceiver<Sensor Type "PCC">, but can call straight through to a single method you have defined.

In a base AntPlusSensor class I have:

protected final void onConnectionResultReceived(AntPluginPcc antPluginPcc,
   
RequestAccessResult resultCodeDeviceState initialDeviceState{
  L
.d("onConnectionResultReceived: " resultCode);

  switch(
resultCode{
  
// Handle result
  
}
 } 


Then in a subclass for each sensor type I would do something like this:

private final IPluginAccessResultReceiver<AntPlusBikePowerPccmPluginAccessResultReceiver =
   new 
IPluginAccessResultReceiver<AntPlusBikePowerPcc>() {

  
@Override
  
public void onResultReceived(AntPlusBikePowerPcc antPlusBikePowerPcc,
    
RequestAccessResult resultCodeDeviceState initialDeviceState{

   onConnectionResultReceived
(antPlusBikePowerPccresultCodeinitialDeviceState);
  
}
 }
     

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Note that I am not sure how the ALREADY_SUBSCRIBED resultCode case should be handled, as discussed here: http://www.thisisant.com/forum/viewthread/4354/      

Signature

blackramlabs.com