本文整理汇总了Java中android.os.HandlerThread.start方法的典型用法代码示例。如果您正苦于以下问题:Java HandlerThread.start方法的具体用法?Java HandlerThread.start怎么用?Java HandlerThread.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.HandlerThread
的用法示例。
在下文中一共展示了HandlerThread.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.os.HandlerThread; //导入方法依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
context = getContext();
telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
config = Configuration.getInstance();
textLoader = Singleton.getInstance(TextLoader.class);
highlightManager = Singleton.getInstance(HighlightManager.class);
highlightManager.setConfig(config);
bookmarkDatabaseHelper = new BookmarkDatabaseHelper(context);
super.onCreate(savedInstanceState);
// Restore preferences
this.uiHandler = new Handler();
HandlerThread bgThread = new HandlerThread("background");
bgThread.start();
this.backgroundHandler = new Handler(bgThread.getLooper());
}
示例2: openDB
import android.os.HandlerThread; //导入方法依赖的package包/类
/**
*修改数据库的存贮路径为.../appkey/userID/,
*必须确保userID存在后才能初始化DBManager
*/
public void openDB() {
RLog.d(TAG, "SealUserInfoManager openDB");
if (mDBManager == null || !mDBManager.isInitialized()) {
mDBManager = DBManager.init(mContext);
mWorkThread = new HandlerThread("sealUserInfoManager");
mWorkThread.start();
mWorkHandler = new Handler(mWorkThread.getLooper());
mFriendDao = getFriendDao();
mGroupsDao = getGroupsDao();
mGroupMemberDao = getGroupMemberDao();
mBlackListDao = getBlackListDao();
mUserInfoCache = new LinkedHashMap<>();
setUserInfoEngineListener();
}
mGetAllUserInfoState = sp.getInt("getAllUserInfoState", 0);
RLog.d(TAG, "SealUserInfoManager mGetAllUserInfoState = " + mGetAllUserInfoState);
}
示例3: init
import android.os.HandlerThread; //导入方法依赖的package包/类
private void init() {
if (isAndroidThingsDevice(this)) {
initPIO();
}
mBackgroundThread = new HandlerThread("BackgroundThread");
mBackgroundThread.start();
mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
mBackgroundHandler.post(mInitializeOnBackground);
// Let the user touch the screen to take a photo
findViewById(R.id.container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mReady.get()) {
Log.i(TAG, "Taking photo");
setReady(false);
mBackgroundHandler.post(mBackgroundClickHandler);
} else {
Log.i(TAG, "Sorry, processing hasn't finished. Try again in a few seconds");
}
}
});
}
开发者ID:androidthings,项目名称:sample-tensorflow-imageclassifier,代码行数:25,代码来源:ImageClassifierActivity.java
示例4: onEnabled
import android.os.HandlerThread; //导入方法依赖的package包/类
@Override
protected void onEnabled(int track, long positionUs, boolean joining)
throws ExoPlaybackException {
super.onEnabled(track, positionUs, joining);
parserIndex = getParserIndex(getFormat(track));
parserThread = new HandlerThread("textParser");
parserThread.start();
parserHelper = new SubtitleParserHelper(parserThread.getLooper(), subtitleParsers[parserIndex]);
}
示例5: startBackgroundThread
import android.os.HandlerThread; //导入方法依赖的package包/类
private void startBackgroundThread() {
Log.i(LOGTAG, "startBackgroundThread");
stopBackgroundThread();
mBackgroundThread = new HandlerThread("CameraBackground");
mBackgroundThread.start();
mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
}
示例6: startBackgroundThread
import android.os.HandlerThread; //导入方法依赖的package包/类
/**
* Starts a background thread and its {@link Handler}.
*/
private void startBackgroundThread() {
mBackgroundThread = new HandlerThread("CameraBackground");
mBackgroundThread.start();
synchronized (mCameraStateLock) {
mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
}
}
示例7: HwAvcEncoder
import android.os.HandlerThread; //导入方法依赖的package包/类
public HwAvcEncoder(final VideoConfig videoConfig, final MediaCodecCallback... callbacks) {
mVideoConfig = videoConfig;
mMediaCodecThread = new HandlerThread("HwAvcEncoderThread");
mMediaCodecThread.start();
mMediaCodecHandler = new Handler(mMediaCodecThread.getLooper());
mVideoEncoder = new MediaCodecVideoEncoder();
mMediaCodecCallbacks = Arrays.asList(callbacks);
}
示例8: FrameSender
import android.os.HandlerThread; //导入方法依赖的package包/类
public FrameSender(final FrameSenderCallback frameSenderCallback) {
this.frameSenderCallback = frameSenderCallback;
final HandlerThread sendHandlerThread = new HandlerThread("send_thread");
sendHandlerThread.start();
sendHandler = new Handler(sendHandlerThread.getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == MESSAGE_READY_TO_CLOSE) {
if (msg.obj != null) {
addFrame((FramePool.Frame) msg.obj);
}
sendFrame(msg.arg1);
frameSenderCallback.close();
sendHandlerThread.quitSafely();
} else if (msg.what == MSG_ADD_FRAME) {
if (msg.obj != null) {
addFrame((FramePool.Frame) msg.obj);
}
sendFrame(msg.arg1);
} else if (msg.what == MSG_START) {
frameSenderCallback.onStart();
}
}
};
}
示例9: onResume
import android.os.HandlerThread; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
backgroundThread = new HandlerThread("handlerThread");
backgroundThread.start();
backgroundHandler = new Handler(backgroundThread.getLooper());
}
示例10: LicenseChecker
import android.os.HandlerThread; //导入方法依赖的package包/类
/**
* @param context a Context
* @param policy implementation of Policy
* @param encodedPublicKey Base64-encoded RSA public key
* @throws IllegalArgumentException if encodedPublicKey is invalid
*/
public LicenseChecker(Context context, Policy policy, String encodedPublicKey) {
mContext = context;
mPolicy = policy;
mPublicKey = generatePublicKey(encodedPublicKey);
mPackageName = mContext.getPackageName();
mVersionCode = getVersionCode(context, mPackageName);
HandlerThread handlerThread = new HandlerThread("background thread");
handlerThread.start();
mHandler = new Handler(handlerThread.getLooper());
}
示例11: onResume
import android.os.HandlerThread; //导入方法依赖的package包/类
@Override
public synchronized void onResume() {
LOGGER.d("onResume " + this);
super.onResume();
handlerThread = new HandlerThread("inference");
handlerThread.start();
handler = new Handler(handlerThread.getLooper());
}
示例12: startBackgroundThread
import android.os.HandlerThread; //导入方法依赖的package包/类
private void startBackgroundThread() {
mBackgroundThread = new HandlerThread("Camera Background");
mBackgroundThread.start();
mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
}
示例13: getTestContentObserver
import android.os.HandlerThread; //导入方法依赖的package包/类
static TestContentObserver getTestContentObserver() {
HandlerThread ht = new HandlerThread("ContentObserverThread");
ht.start();
return new TestContentObserver(ht);
}
示例14: initLooper
import android.os.HandlerThread; //导入方法依赖的package包/类
private void initLooper() {
mThreadHandler = new HandlerThread("CAMERA2");
mThreadHandler.start();
mHandler = new Handler(mThreadHandler.getLooper());
}
示例15: BackgroundExecutor
import android.os.HandlerThread; //导入方法依赖的package包/类
BackgroundExecutor() {
HandlerThread handlerThread = new HandlerThread("queue-handler");
handlerThread.start();
this.threadId = handlerThread.getId();
this.handler = new Handler(handlerThread.getLooper());
}