本文整理匯總了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);
}
示例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);
}
示例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);
}
}
示例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();
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
}
}
示例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;
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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);
}