public abstract class SCActivity
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
SCActivity.SCThread abstract class and and the handleSCMessage(Message) function, which
receives the card SCActivity.Events message such as card inserted.
In this implementation, the client implements the SCActivity.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.
SCActivity.SCThreadis created to run following jobs: 1.1 SendingSCActivity.Events.WAITING_READER_CONNECT1.2 Reader is connected to the phone 1.3 SendingSCActivity.Events.READER_CONNECTED2.1 SendingSCActivity.Events.WAITING_CARD_INSERT2.2 Card is inserted into the reader 2.3 SendingSCActivity.Events.CARD_INSERTED3.1 SendingSCActivity.Events.RUN_COMMANDS_BEFORE3.2 CallSCActivity.SCThread.RunCommands()function to execute the card commands 3.3 SendingSCActivity.Events.RUN_COMMANDS_AFTER
| Modifier and Type | Class and Description |
|---|---|
static class |
SCActivity.Events
Smart card reader event message.
|
protected class |
SCActivity.SCThread
An abstract class, which facilitates a thread dedicated for smart card
communication.
|
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 |
|---|
SCActivity() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract SCActivity.SCThread |
createSCThread()
Subclasses should implement this method by returning a concrete subclass
of
SCActivity.SCThread. |
protected void |
DebugCommand() |
protected void |
ExecuteCard()
Subclasses must call this method to start the smart card thread
SCActivity.SCThread. |
protected abstract void |
handleSCMessage(android.os.Message msg)
SmartCard message Handler
|
void |
onCreate(android.os.Bundle savedInstanceState) |
protected void |
onPause()
Subclasses should call this method from their own onPause() if
overloaded.
|
protected void |
SendMessage(int what,
java.lang.Object obj) |
protected void |
SendMessage(SCActivity.Events what) |
protected void |
SendMessage(SCActivity.Events 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, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onRestart, onRestoreInstanceState, onResume, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onStop, 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 onPause()
onPause in class android.app.Activityprotected void ExecuteCard()
SCActivity.SCThread.protected abstract SCActivity.SCThread createSCThread()
SCActivity.SCThread.SCActivity.SCThreadprotected 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(SCActivity.Events what, java.lang.Object obj)
protected final void SendMessage(int what,
java.lang.Object obj)
protected final void SendMessage(SCActivity.Events what)
Copyright © 2025. All rights reserved.