当前位置: 首页>>代码示例>>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;未经允许,请勿转载。