本文整理汇总了Java中android.os.Message类的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Message类属于android.os包,在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectionFailed
import android.os.Message; //导入依赖的package包/类
/**
* Indicate that the connection attempt failed and notify the UI Activity.
*/
private void connectionFailed() {
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(Constants.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString(Constants.TOAST, "Unable to connect device");
msg.setData(bundle);
mHandler.sendMessage(msg);
mState = STATE_NONE;
// Update UI title
updateUserInterfaceTitle();
// Start the service over to restart listening mode
BluetoothChatService.this.startBT();
}
示例2: onStartCommand
import android.os.Message; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Running = true;
// when the activity starts the service, it expects to start it for a new wallet
// the service is possibly still occupied with saving the last opened wallet
// so we queue the open request
// this should not matter since the old activity is not getting updates
// and the new one is not listening yet (although it will be bound)
Timber.d("onStartCommand()");
// For each start request, send a message to start a job and deliver the
// start ID so we know which request we're stopping when we finish the job
Message msg = mServiceHandler.obtainMessage();
msg.arg2 = START_SERVICE;
if (intent != null) {
msg.setData(intent.getExtras());
mServiceHandler.sendMessage(msg);
return START_STICKY;
} else {
// process restart - don't do anything - let system kill it again
stop();
return START_NOT_STICKY;
}
}
示例3: handleMessage
import android.os.Message; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
final int userId = msg.arg2;
final int n = mCallbacks.beginBroadcast();
for (int i = 0; i < n; i++) {
final IPackageInstallerCallback callback = mCallbacks.getBroadcastItem(i);
final VUserHandle user = (VUserHandle) mCallbacks.getBroadcastCookie(i);
// TODO: dispatch notifications for slave profiles
if (userId == user.getIdentifier()) {
try {
invokeCallback(callback, msg);
} catch (RemoteException ignored) {
}
}
}
mCallbacks.finishBroadcast();
}
示例4: handleMessage
import android.os.Message; //导入依赖的package包/类
public void handleMessage(Message msg) {
super.handleMessage(msg);
String smsg = msg.obj.toString();
if (msg.what == 0) {
try {
LEYUApplication.dev_access_token = ((JSONObject) new JSONTokener(smsg)
.nextValue()).getString("access_token");
LEYUApplication.set("leyu_dev_access_token", LEYUApplication.dev_access_token);
LEYUApplication.this._callback.ReturnAccessToken(LEYUApplication
.dev_access_token);
} catch (JSONException ex) {
ex.printStackTrace();
LEYUApplication.this._callback.onFailed(ex.getMessage());
}
} else if (msg.what == 1) {
LEYUApplication.this._callback.OnCompleted(smsg);
} else if (msg.what == 2) {
LEYUApplication.this._callback.onFailed(smsg);
}
}
示例5: goNext
import android.os.Message; //导入依赖的package包/类
private void goNext(final int nextIndex) {
if (this.mHandler == null || this.mList == null) {
FileDownloadLog.w(this, "need go next %d, but params is not ready %s %s",
nextIndex, this.mHandler, this.mList);
return;
}
Message nextMsg = this.mHandler.obtainMessage();
nextMsg.what = WHAT_SERIAL_NEXT;
nextMsg.arg1 = nextIndex;
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(SerialHandlerCallback.class, "start next %s %s",
this.mList == null ? null : this.mList.get(0) == null ? null :
this.mList.get(0).getOrigin().getListener(), nextMsg.arg1);
}
this.mHandler.sendMessage(nextMsg);
}
示例6: show
import android.os.Message; //导入依赖的package包/类
public void show(View parent){
this.showAtLocation(parent, Gravity.CENTER,0,0);
new Thread(new Runnable(){
@Override
public void run() {
//此处while的条件alpha不能<= 否则会出现黑屏
while(layoutParams.alpha > 0.5f){
try {
Thread.sleep(6);
} catch (InterruptedException e) {
e.printStackTrace();
}
Message msg =mHandler.obtainMessage();
msg.what = 1;
layoutParams.alpha -= 0.01f;
msg.obj = layoutParams;
mHandler.sendMessage(msg);
}
}
}).start();
}
示例7: setPortrait
import android.os.Message; //导入依赖的package包/类
private void setPortrait(){
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
pngBM = User.getInstance().getUserPortrait();
Message msg = new Message();
msg.what = 0;
handler.sendMessage(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
});
thread.start();
}
示例8: register
import android.os.Message; //导入依赖的package包/类
public OkBus register(int tag, final Event ev, int thread) {
SparseArray<Event> mEvent = new SparseArray<>();
mEvent.put(thread, ev);
if (mEventList.get(tag) != null) {
mEventList.get(tag).add(mEvent);
} else {
List<SparseArray<Event>> mList = new ArrayList<>();
mList.add(mEvent);
mEventList.put(tag, mList);
}
LogUtils.e("Bus register", tag + " :" + mEventList.get(tag).size());
if (mStickyEventList.get(tag) != null) {//注册时分发粘连事件
final Message msg = new Message();
msg.obj = mStickyEventList.get(tag);
msg.what = tag;
callEvent(msg, ev, thread);
LogUtils.e("mStickyEvent register and onEvent", tag + " :" + mEventList.get(tag).size());
}
return this;
}
示例9: handleMessage
import android.os.Message; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_FADE_OUT:
log.i("isfu123", "isfu123");
if (isShowing){
hide(1);
}
break;
case MESSAGE_HIDE_BOX:
$.id(R.id.app_video_center_box_right).gone();
$.id(R.id.app_video_center_box_left).gone();
$.id(R.id.app_video_top_box_right).gone();
show(defaultTimeout,true);
break;
case MESSAGE_SHOW_BOX:
show(defaultTimeout,true);
break;
case MESSAGE_SEEK_NEW_POSITION:
break;
case MESSAGE_RESTART_PLAY:
play(url);
break;
}
}
示例10: preview
import android.os.Message; //导入依赖的package包/类
public final void preview(boolean start, SurfaceView view, int uid) {
if (Thread.currentThread() != this) {
log.warn("preview() - worker thread asynchronously " + start + " " + view + " " + (uid & 0XFFFFFFFFL));
Message envelop = new Message();
envelop.what = ACTION_WORKER_PREVIEW;
envelop.obj = new Object[]{start, view, uid};
mWorkerHandler.sendMessage(envelop);
return;
}
ensureRtcEngineReadyLock();
if (start) {
mRtcEngine.setupLocalVideo(new VideoCanvas(view, VideoCanvas.RENDER_MODE_HIDDEN, uid));
mRtcEngine.startPreview();
} else {
mRtcEngine.stopPreview();
}
}
示例11: handleMessage
import android.os.Message; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case REQUEST_UPDATE:
UIProgressRequestListener uiProgressRequestListener = mUIProgressRequestListenerWeakReference.get();
if (uiProgressRequestListener != null) {
//获得进度实体类
ProgressModel progressModel = (ProgressModel) msg.obj;
//回调抽象方法
uiProgressRequestListener.onUIRequestProgress(progressModel.getCurrentBytes(), progressModel.getContentLength(), progressModel.isDone());
}
break;
default:
super.handleMessage(msg);
break;
}
}
示例12: handleMessage
import android.os.Message; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
InitActivity ctx = (InitActivity) mContext.get();
switch (msg.what) {
case 0:
ctx.mPD.dismiss();
Intent src = ctx.getIntent();
Intent i = new Intent();
i.setClassName(src.getStringExtra("package"), src.getStringExtra("className"));
i.setData(src.getData());
i.putExtras(src);
i.putExtra(FROM_ME, true);
ctx.startActivity(i);
ctx.finish();
break;
}
}
示例13: updateSub
import android.os.Message; //导入依赖的package包/类
private void updateSub(int subType, byte[] bytes, String encoding, int width, int height) {
if (mEventHandler != null) {
Message m = mEventHandler.obtainMessage(MEDIA_TIMED_TEXT, width, height);
Bundle b = m.getData();
if (subType == SUBTITLE_TEXT) {
b.putInt(MEDIA_SUBTITLE_TYPE, SUBTITLE_TEXT);
if (encoding == null) {
b.putString(MEDIA_SUBTITLE_STRING, new String(bytes));
} else {
try {
b.putString(MEDIA_SUBTITLE_STRING, new String(bytes, encoding.trim()));
} catch (UnsupportedEncodingException e) {
Log.e("updateSub", e);
b.putString(MEDIA_SUBTITLE_STRING, new String(bytes));
}
}
} else if (subType == SUBTITLE_BITMAP) {
b.putInt(MEDIA_SUBTITLE_TYPE, SUBTITLE_BITMAP);
b.putByteArray(MEDIA_SUBTITLE_BYTES, bytes);
}
mEventHandler.sendMessage(m);
}
}
示例14: after
import android.os.Message; //导入依赖的package包/类
@Override
protected void after(XParam param) throws Throwable {
if (mMethod == Methods.next) {
Message msg = (Message) param.getResult();
if (msg != null) {
if (msg.obj instanceof Intent) {
Intent intent = (Intent) msg.obj;
if (intent != null)
if (checkIntent(Binder.getCallingUid(), intent))
param.setResult(null);
}
}
} else if (mMethod == Methods.handleReceiver) {
// Do nothing
} else
Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
}
示例15: init
import android.os.Message; //导入依赖的package包/类
private void init() {
handler = new Handler(getLooper()) {
@Override
public void handleMessage(Message msg) {
switch (msg.what){
case CHECK_HITALK_CONVERSATION:
MonitorEvent monitorEvent = (MonitorEvent) msg.obj;
Message newMsg = new Message();
newMsg.copyFrom(msg);
if (!monitorEvent.check()) {
IMMEDIATE_TIMES ++;
monitorEvent.run();
handler.sendMessageDelayed(newMsg,
LOOP_IMMEDIATE + (IMMEDIATE_TIMES / 3) * LOOP_INCREAMENT);
} else {
IMMEDIATE_TIMES = 0;
handler.sendMessageDelayed(newMsg,
LOOP_TIME);
}
break;
}
}
};
}