public abstract class BTActivity
extends android.app.Activity
It is used by creating a concrete Activity in your application, which extends this class. This class then takes care of proper creation and abortion of the reader connection and of a dedicated thread for smart card communication.
In the intended usage the client should extend this class and implement
createSCThread(), which should return an implementation of the
BTActivity.SCThread abstract class and and the handleSCMessage(Message) function, which
receives the card BTActivity.Events message such as card inserted.
In this implementation, the client implements the BTActivity.SCThread.RunCommands() method,
which gets called as soon as card inserted into the reader.
To start the smart card thread, client could call ExecuteCard() from UI control, ex: Button onClick.
BTActivity.SCThreadis created to run following jobs: 1.1 SendingBTActivity.Events.WAITING_READER_CONNECT1.2 Reader is connected to the phone 1.3 SendingBTActivity.Events.READER_CONNECTED2.1 SendingBTActivity.Events.WAITING_CARD_INSERT2.2 Card is inserted into the reader 2.3 SendingBTActivity.Events.CARD_INSERTED3.1 SendingBTActivity.Events.RUN_COMMANDS_BEFORE3.2 CallBTActivity.SCThread.RunCommands()function to execute the card commands 3.3 SendingBTActivity.Events.RUN_COMMANDS_AFTER
| Modifier and Type | Class and Description |
|---|---|
static class |
BTActivity.Events
Smart card reader event message.
|
protected class |
BTActivity.SCThread
An abstract class, which facilitates a thread dedicated for smart card
communication.
|
| Modifier and Type | Field and Description |
|---|---|
protected android.bluetooth.BluetoothAdapter |
mBluetoothAdapter |
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OKACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE| Constructor and Description |
|---|
BTActivity() |
| Modifier and Type | Method and Description |
|---|---|
protected IReader |
createReader()
Subclasses may override this method for alternate creation modes of the
reader instance.
|
protected abstract BTActivity.SCThread |
createSCThread()
Subclasses should implement this method by returning a concrete subclass
of
BTActivity.SCThread. |
protected void |
DebugCommand() |
protected void |
ExecuteCard()
Subclasses must call this method to start the smart card thread
BTActivity.SCThread. |
protected abstract void |
handleSCMessage(android.os.Message msg)
SmartCard message Handler
|
void |
onCreate(android.os.Bundle savedInstanceState) |
protected void |
onStop()
Subclasses should call this method from their own onPause() if
overloaded.
|
protected void |
SendMessage(BTActivity.Events what) |
protected void |
SendMessage(BTActivity.Events what,
java.lang.Object obj) |
protected void |
SendMessage(int what,
java.lang.Object obj) |
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isFinishing, isTaskRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onActivityResult, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDestroy, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onNewIntent, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPause, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onRestart, onRestoreInstanceState, onResume, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setIntent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenubindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiverpublic void onCreate(android.os.Bundle savedInstanceState)
onCreate in class android.app.Activityprotected void onStop()
onStop in class android.app.Activityprotected void ExecuteCard()
BTActivity.SCThread.protected abstract BTActivity.SCThread createSCThread()
BTActivity.SCThread.BTActivity.SCThreadprotected IReader createReader() throws java.lang.InterruptedException, SCException
SCExceptionjava.lang.InterruptedExceptionprotected void DebugCommand()
protected abstract void handleSCMessage(android.os.Message msg)
example:
@Override
protected void handleSCMessage(Message msg) {
Events what = Events.values()[msg.what];
switch (what)
{
case WAITING_READER_CONNECT:
mMessage.setText("Connecting reader.");
mWaitCard.setVisibility(View.VISIBLE);
break;
case READER_CONNECTED:
mWaitCard.setVisibility(View.GONE);
break;
case WAITING_CARD_INSERT:
mMessage.setText("Please inser card.");
mWaitCard.setVisibility(View.VISIBLE);
break;
case WAITING_CARD_REMOVE:
mMessage.setText("Please remove card.");
mWaitCard.setVisibility(View.VISIBLE);
break;
case CARD_INSERTED:
case CARD_REMOVED:
case RUN_COMMANDS_AFTER:
mWaitCard.setVisibility(View.GONE);
break;
case RUN_COMMANDS_BEFORE:
mMessage.setText("Reading Card.");
mWaitCard.setVisibility(View.VISIBLE);
break;
case RUN_COMMANDS_ERROR:
mWaitCard.setVisibility(View.GONE);
Exception e = (Exception)msg.obj;
mMessage.setText(e.getMessage());
break;
}
}
protected final void SendMessage(BTActivity.Events what, java.lang.Object obj)
protected final void SendMessage(int what,
java.lang.Object obj)
protected final void SendMessage(BTActivity.Events what)
Copyright © 2025. All rights reserved.