public class SA extends Object implements com.samsung.android.sdk.SsdkInterface
All Samsung SDKs, including the Samsung Accessory SDK, provide a uniform interface for initialization,
checking whether features are enabled, and getting the SDK version info. The application must call
initialize(Context)
to initialize the Samsung Accessory SDK before using it. To get the version
number (int
) and name (string
) of the Samsung Accessory SDK, call getVersionCode()
and getVersionName()
.
public class HelloAccessory extends SAAgent {
@Override
public void onCreate() {
super.onCreate();
SA mAccessory = new SA();
try {
mAccessory.initialize(this);
} catch (SsdkUnsupportedException e) {
// Error Handling
} catch (Exception e1) {
// Error Handling
}
int mVersionCode = mAccessory.getVersionCode();
String mVersionName = mAccessory.getVersionName();
}
}
For more information about using Accessory, please refer to the Accessory Programming Guide.
Modifier and Type | Field and Description |
---|---|
static int |
DEVICE_ACCESSORY
Accessory feature ID
|
static int |
SERVICE_MESSAGE
Message Service feature ID.
|
Constructor and Description |
---|
SA()
Creates an SA instance.
|
Modifier and Type | Method and Description |
---|---|
int |
getVersionCode()
Returns the version number of the Samsung Accessory SDK.
|
String |
getVersionName()
Returns the version name of the Samsung Accessory SDK.
|
void |
initialize(Context context)
Initializes an instance of the Samsung Accessory SDK.
|
boolean |
isFeatureEnabled(int type)
Returns
true if the Accessory feature on the device is enabled. |
public static final int DEVICE_ACCESSORY
public static final int SERVICE_MESSAGE
public int getVersionCode()
public String getVersionName()
public void initialize(Context context) throws SsdkUnsupportedException
context
- The Context for your application.SsdkUnsupportedException
- Thrown if the device was not made by Samsung, doesn't support the feature, or the SDK
version is not matched.IllegalArgumentException
- Thrown if the Context passed is null or invalid.SecurityException
- Thrown if the required permission is not included in the AndroidManifest.xml file.
This does not occur in other companies' or non-Samsung devices.public boolean isFeatureEnabled(int type)
true
if the Accessory feature on the device is enabled.type
- The feature ID(must be (DEVICE_ACCESSORY
, SERVICE_MESSAGE
)).true
if the Accessory feature is available on the device, else false
IllegalArgumentException
- Thrown if the feature ID passed is not valid.Copyright © Samsung Electronics, Co., Ltd. All rights reserved.