Socket ScanAPI Reference
Example:
Objective C:
/**
* called each time a device connects to the host
* @param result contains the result of the connection
* @param newDevice contains the device information
*/
-(void)onDeviceArrival:(SKTRESULT)result Device:(DeviceInfo*)deviceInfo{
// create a device info object to display the device main
// information in the table view
if (SKTSUCCESS(result)) {
DeviceInfo* devicelisted=[[self.devicelist objectAtIndex:0] valueForKey:kViewControllerKey];
if (devicelisted==nil) {
[self.devicelist removeObjectAtIndex:0];
}
[self.devicelist addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
_devicecount++;
_lastConnected=deviceInfo;
_selectedDevice=nil;// for now no device is selected
if ([[deviceInfo getTypeString] compare:@"SoftScan"]==0) {
UIViewController* pThis=self;
NSMutableDictionary* overlayParameter=[[NSMutableDictionary alloc]init];
[overlayParameter setValue:pThis forKey:[NSString stringWithCString:kSktScanSoftScanContext
encoding:NSASCIIStringEncoding]];
NSLog(@"Send Context:%p",(UIViewController*)[overlayParameter valueForKey:[NSString
stringWithCString:kSktScanSoftScanContext encoding:NSASCIIStringEncoding]]);
[_scanApiHelper postSetOverlayView:deviceInfo OverlayView:overlayParameter Target:self
Response:@selector(onSetProperty:)];
[overlayParameter release];
}
[self performSelectorOnMainThread:@selector(updateView) withObject:nil waitUntilDone:NO];
#ifdef _SCANNER_REGISTRATION
// Get the Bluetooth address for check if the Scanner is
// Registered (Developer Program)
// the Registration check will be initiated in the onBdAddress
// callback that should have the Bluetooth address of the scanner
[_scanApiHelper postGetBtAddress:_lastConnected Target:self
Response:@selector(onBtAddressForRegistration:)];
#endif
}
else {
UIAlertView *alert=[[UIAlertView alloc]
[alert show];
[alert release];
}
}
Java example (Android only):
scanButton.setOnClickListener(
© 2013 Socket Mobile, Inc.
[deviceInfo getName], kTitleKey,
@"Connected Scanner", kExplainKey,
deviceInfo, kViewControllerKey,
nil]];
initWithTitle:@"Error"
message:@"Unable to open the scanner"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
123/152
Need help?
Do you have a question about the ScanAPI and is the answer not in the manual?