Handler 基本用法

Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, rawResult);
			Bundle bundle = new Bundle();
			bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
			message.setData(bundle);
			//Log.d(TAG, "Sending decode succeeded message...");
			message.sendToTarget();
if (message.what == R.id.decode_succeeded) {
			Log.d(TAG, "Got decode succeeded message");
			state = State.SUCCESS;
			Bundle bundle = message.getData();
			Bitmap barcode = bundle == null ? null :
				(Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);

			decodeCallback.handleDecode((Result) message.obj, barcode);
removeMessages(R.id.decode_succeeded);

    

 

你可能感兴趣的:(Handler 基本用法)