當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.obtain方法代碼示例

本文整理匯總了Java中android.os.Message.obtain方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.obtain方法的具體用法?Java Message.obtain怎麽用?Java Message.obtain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Message的用法示例。


在下文中一共展示了Message.obtain方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: quitSynchronously

import android.os.Message; //導入方法依賴的package包/類
public void quitSynchronously() {
    state = State.DONE;
    cameraManager.stopPreview();
    Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit);
    quit.sendToTarget();
    try {
        // Wait at most half a second; should be enough time, and onPause() will timeout quickly
        decodeThread.join(500L);
    } catch (InterruptedException e) {
        // continue
    }

    // Be absolutely sure we don't send any queued up messages
    removeMessages(R.id.decode_succeeded);
    removeMessages(R.id.decode_failed);
}
 
開發者ID:xiong-it,項目名稱:ZXingAndroidExt,代碼行數:17,代碼來源:CaptureActivityHandler.java

示例2: quitSynchronously

import android.os.Message; //導入方法依賴的package包/類
public void quitSynchronously() {
  state = State.DONE;
  cameraManager.stopPreview();
  Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit);
  quit.sendToTarget();
  try {
    // Wait at most half a second; should be enough time, and onPause() will timeout quickly
    decodeThread.join(500L);
  } catch (InterruptedException e) {
    // continue
  }

  // Be absolutely sure we don't send any queued up messages
  removeMessages(R.id.decode_succeeded);
  removeMessages(R.id.decode_failed);
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:17,代碼來源:CaptureActivityHandler.java

示例3: onServiceConnected

import android.os.Message; //導入方法依賴的package包/類
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
    // Ignore this call if we disconnected in the meantime.
    if (mContext == null) return;

    mService = new Messenger(service);
    mComponentName = name;
    try {
        Message registerClientMessage = Message.obtain(
                null, REQUEST_REGISTER_CLIENT);
        registerClientMessage.replyTo = mMessenger;
        Bundle b = mGsaHelper.getBundleForRegisteringGSAClient(mContext);
        registerClientMessage.setData(b);
        registerClientMessage.getData().putString(
                KEY_GSA_PACKAGE_NAME, mContext.getPackageName());
        mService.send(registerClientMessage);
        // Send prepare overlay message if there is a pending GSA context.
    } catch (RemoteException e) {
        Log.w(SERVICE_CONNECTION_TAG, "GSAServiceConnection - remote call failed", e);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:22,代碼來源:GSAServiceClient.java

示例4: onClick

import android.os.Message; //導入方法依賴的package包/類
@Override
public void onClick(View v) {
    final Message m;
    if (v == mButtonPositive && mButtonPositiveMessage != null) {
        m = Message.obtain(mButtonPositiveMessage);
    } else if (v == mButtonNegative && mButtonNegativeMessage != null) {
        m = Message.obtain(mButtonNegativeMessage);
    } else if (v == mButtonNeutral && mButtonNeutralMessage != null) {
        m = Message.obtain(mButtonNeutralMessage);
    } else {
        m = null;
    }

    if (m != null) {
        m.sendToTarget();
    }

    // Post a message so we dismiss after the above handlers are executed
    mHandler.obtainMessage(ButtonHandler.MSG_DISMISS_DIALOG, MongolAlertDialog.this)
            .sendToTarget();
}
 
開發者ID:suragch,項目名稱:mongol-library,代碼行數:22,代碼來源:MongolAlertDialog.java

示例5: setCameraToPreview

import android.os.Message; //導入方法依賴的package包/類
public boolean setCameraToPreview(boolean isBack) {
    if (!isBack && !CameraUtils.checkFrontCamera(getActivity().getApplicationContext()))
        return false;
    if (isChangingPreview)
        return false;
    isChangingPreview = true;
    Message msg = Message.obtain(null, CameraHeadService.SET_CAMERA_PREVIEW_TYPE);
    msg.replyTo = mMessenger;
    Bundle b = new Bundle();
    b.putBoolean("isBack", isBack);
    msg.setData(b);
    if (mService != null) {
        try {
            mService.send(msg);
        } catch (RemoteException e) {
            return false;
        }
    }
    isBackPreview = isBack;
    return true;
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:22,代碼來源:ColorDetectionShield.java

示例6: quitSynchronously

import android.os.Message; //導入方法依賴的package包/類
public void quitSynchronously() {
	state = State.DONE;
	cameraManager.stopPreview();
	Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit);
	quit.sendToTarget();

	try {
		// Wait at most half a second; should be enough time, and onPause()
		// will timeout quickly
		decodeThread.join(500L);
	} catch (InterruptedException e) {
		// continue
	}

	// Be absolutely sure we don't send any queued up messages
	removeMessages(R.id.decode_succeeded);
	removeMessages(R.id.decode_failed);
}
 
開發者ID:dufangyu1990,項目名稱:LeCatApp,代碼行數:19,代碼來源:CaptureActivityHandler.java

示例7: schedule

import android.os.Message; //導入方法依賴的package包/類
public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) {
    if (this.unsubscribed) {
        return Subscriptions.unsubscribed();
    }
    Subscription scheduledAction = new ScheduledAction(this.hook.onSchedule(action), this.handler);
    Message message = Message.obtain(this.handler, scheduledAction);
    message.obj = this;
    this.handler.sendMessageDelayed(message, unit.toMillis(delayTime));
    if (!this.unsubscribed) {
        return scheduledAction;
    }
    this.handler.removeCallbacks(scheduledAction);
    return Subscriptions.unsubscribed();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:15,代碼來源:LooperScheduler.java

示例8: sendReplyCommand

import android.os.Message; //導入方法依賴的package包/類
/**
 * Send some reply message to the ipc.
 *
 * @param mbsService MbsService of reply.
 * @param cmd        Command should be sent, as reply.
 */
private void sendReplyCommand(int mbsService, int replyTo, CmdArg cmd) {
    Message msg = Message.obtain(null, mbsService);
    Bundle bundle = new Bundle();
    bundle.putInt("cmd", cmd.getCMD());
    bundle.putString("value", cmd.getValue());
    msg.setData(bundle);
    msg.arg2 = replyTo;
    handleMessage(msg);
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:16,代碼來源:IPCService.java

示例9: addClusterItem

import android.os.Message; //導入方法依賴的package包/類
/**
 * 添加一個聚合點
 *
 * @param item
 */
public void addClusterItem(ClusterItem item) {
    Message message = Message.obtain();
    message.what = SignClusterHandler.CALCULATE_SINGLE_CLUSTER;
    message.obj = item;
    mSignClusterHandler.sendMessage(message);
}
 
開發者ID:xiaogu-space,項目名稱:android-cluster-marker-master,代碼行數:12,代碼來源:ClusterOverlay.java

示例10: processEvent

import android.os.Message; //導入方法依賴的package包/類
private void processEvent(Message request) {
	/**
	 * Get the Event that is inside the message, and the Messenger to reply in the case that an
	 * alert is produced
	 */
	Bundle bundleEvent = request.getData();
	LogicTupleEvent event = bundleEvent.getParcelable(MagpieActivity.MAGPIE_EVENT);

	final Messenger replyMessenger = request.replyTo;

	for (MagpieAgent agent : mListOfAgents.values()) {
		// Send the event only to the interested agents
		if (agent.getInterests().contains(event.getType())) {
			Log.i(TAG, "Agent with Id " + agent.getId() + " and name " + agent.getName() + " activated");
			agent.senseEvent(event);
			agent.activate();
		}
	}

	while (!mQueueOfAlerts.isEmpty()) {
		// Take the alert
		LogicTupleEvent alert = (LogicTupleEvent) mQueueOfAlerts.poll();

		// Prepare the message containg the alert to be sent to the MagpieActivity
		Message reply = Message.obtain();
		reply.what = Environment.NEW_EVENT;
		Bundle alertBundle = new Bundle();
		alertBundle.putParcelable(MagpieActivity.MAGPIE_EVENT, alert);
		reply.setData(alertBundle);

		// Send back the alert
		try {
			replyMessenger.send(reply);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
}
 
開發者ID:kflauri2312lffds,項目名稱:Android_watch_magpie,代碼行數:39,代碼來源:Environment.java

示例11: sendMessageSynchronously

import android.os.Message; //導入方法依賴的package包/類
/**
 * Send the Message synchronously.
 *
 * @param what
 * @param obj
 * @return reply message or null if an error.
 */
public Message sendMessageSynchronously(int what, Object obj) {
    Message msg = Message.obtain();
    msg.what = what;
    msg.obj = obj;
    Message resultMsg = sendMessageSynchronously(msg);
    return resultMsg;
}
 
開發者ID:jasonwang18,項目名稱:pluginMVPM,代碼行數:15,代碼來源:AsyncChannel.java

示例12: send

import android.os.Message; //導入方法依賴的package包/類
private void send(int method, Bundle params) {
    Message m = Message.obtain(null, method);
    m.setData(params);
    try {
        mMsg.send(m);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
開發者ID:snoozinsquatch,項目名稱:unity-obb-downloader,代碼行數:10,代碼來源:DownloaderServiceMarshaller.java

示例13: invalidatePreview

import android.os.Message; //導入方法依賴的package包/類
public void invalidatePreview(float x, float y) throws RemoteException {
    Message msg = Message.obtain(null, CameraHeadService.INVALIDATE_PREVIEW);
    msg.replyTo = mMessenger;
    Bundle b = new Bundle();
    b.putFloat("x", x);
    b.putFloat("y", y);
    msg.setData(b);
    if (mService != null)
        mService.send(msg);
    else
        bindService();

}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:14,代碼來源:ColorDetectionShield.java

示例14: initSenseState

import android.os.Message; //導入方法依賴的package包/類
@Override
public void initSenseState() {
    mSensePresenter.regitsterSmallPlatformReciever();
    checkSense();
    if(!mSensePresenter.isHotelEnvironment()&&AppUtils.isWifiNetwork(this)) {
        LogUtils.d("savor:checkSense 當前為非酒店環境,延遲獲取小平台地址");
        Message message = Message.obtain();
        message.what = CHECK_PLATFORM_URL;
        message.obj = checkcount;
        mHandler.sendMessageDelayed(message,2000);
    }
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:13,代碼來源:HotspotMainActivity.java

示例15: animateText

import android.os.Message; //導入方法依賴的package包/類
public void animateText(CharSequence text) {
    if (text == null) {
        throw new RuntimeException("text must not be null");
    }

    mText = text;
    showingIncrease = charIncrease;
    setText("");
    Message message = Message.obtain();
    message.what = SHOWING;
    handler.sendMessage(message);
}
 
開發者ID:totond,項目名稱:YGuider,代碼行數:13,代碼來源:TyperTextView.java


注:本文中的android.os.Message.obtain方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。