public class UnitermService
extends Service
This is the main way and application should interact with Uniterm.
The service itself uses the UnitermNativeBridge
for interacting with Uniterm.
An integrater should not use UnitermNativeBridge
directly.
The service uses the following permissions:
The service itself provides the AndroidManifest information. An integrator does not need to add anything to their manifest to facility using the service.
Due to the unique ways aar packages are merged into an project that uses it a custom uniterm.ini file can be provided that will be used in place of the default one. In res/raw put a file called uniterm_ini (notice an underscore instead of a period) to override the default file.
Example usage for an application using the service:
private IUnitermService mUnitermService = null;
private ServiceConnection mUnitermServiceConnection = new ServiceConnection() {
\@Override
public void onServiceConnected(ComponentName name, IBinder service) {
synchronized (this) {
mUnitermService = IUnitermService.Stub.asInterface(service);
}
}
\@Override
public void onServiceDisconnected(ComponentName name) {
synchronized (this) {
mUnitermService = null;
}
}
};
\@Override
onCreate(Bundle savedInstanceState) {
Intent i = new Intent(this, UnitermService.class);
this.bindService(i, mUnitermServiceConnection, Context.BIND_AUTO_CREATE);
}
protected void finalize() {
if (mUnitermServiceConnection != null)
this.unbindService(mUnitermServiceConnection);
}
// Connected to a UI button.
doRunTrans(View v) {
Bundle request = new Bundle();
Bundle result;
request.putString("u_action", "version");
try {
result = mUnitermService.runTrans(request);
} catch (Exception e) {
result = new Bundle();
result.put("code", "DENY");
result.put("verbiage", e.getMessage());
}
// Do something with result.
}
If using the UniTerm SDK it must be included directly in the application and not though the .aar library. The SDK .aar is designed to connect to an exported UniTerm service. Using the UniTerm Service .aar it is not exported so the connection to UniTerm within the SDK needs to be changed slightly to use an explicit connection. In `private synchronized void connectUniterm`:
+ Intent i = new Intent(UnitermService.class);
- Intent i = new Intent();
- i.setClassName("com.monetra.uniterm", "com.monetra.uniterm.service.UnitermService");
The service itself provides the IUnitermService.aidl and the public aidl file should not
be included in the project. The Service uses an aidl file that has an additional function
for modify config. This modify config function is only allowed to be used by the service
when it is not exported. This is the default for the .aar. If this is overridden and the
service is exported modify config will not longer function.
Constructor and Description |
---|
UnitermService() |
Modifier and Type | Method and Description |
---|---|
IBinder |
onBind(Intent intent) |
void |
onCreate() |
void |
onDestroy() |
int |
onStartCommand(Intent intent,
int flags,
int startId) |