Java 类android.os.Message 实例源码
项目:iconsole-android
文件:BluetoothChatService.java
/**
* 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();
}
项目:xmrwallet
文件:WalletService.java
@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;
}
}
项目:container
文件:VPackageInstallerService.java
@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();
}
项目:boohee_v5.6
文件:LEYUApplication.java
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);
}
}
项目:GitHub
文件:QueuesHandler.java
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);
}
项目:3DPrint-Controller
文件:ModelInfoPopupWindow.java
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();
}
项目:19porn
文件:PersonInfoActivity.java
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();
}
项目:GitHub
文件:OkBus.java
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;
}
项目:live_master
文件:GiraffePlayer.java
@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;
}
}
项目:OpenVideoCall-Android
文件:WorkerThread.java
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();
}
}
项目:Hotspot-master-devp
文件:UIProgressRequestListener.java
@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;
}
}
项目:TPlayer
文件:InitActivity.java
@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;
}
}
项目:TPlayer
文件:MediaPlayer.java
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);
}
}
项目:XPrivacy
文件:XActivityThread.java
@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());
}
项目:Hitalk
文件:HitalkMonitor.java
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;
}
}
};
}
项目:-Pod
文件:MusicFragment.java
@Override
public void onReceive(Context context, Intent intent) {
String key = intent.getStringExtra(Constants.ACTION_KEY);
Message message = Message.obtain(handler);
switch (key) {
case Constants.ACTION_OK:
message.what = 0;
break;
case Constants.ACTION_PREV:
message.what = 1;
break;
case Constants.ACTION_NEXT:
message.what = 2;
break;
case Constants.ACTION_MENU:
message.what = 3;
break;
case Constants.ACTION_PLAY:
message.what = 4;
break;
}
handler.sendMessage(message);
}
项目:Aurora
文件:DownloadSerialQueue.java
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case WHAT_NEXT:
try {
synchronized (finishCallback) {
if (paused) break;
workingTask = mTasks.take();
workingTask.addFinishListener(finishCallback)
.start();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
break;
}
return false;
}
项目:letv
文件:g.java
private g() {
if (this.f == null) {
this.f = new HandlerThread("opensdk.report.handlerthread", 10);
this.f.start();
}
if (this.f.isAlive() && this.f.getLooper() != null) {
this.g = new Handler(this, this.f.getLooper()) {
final /* synthetic */ g a;
public void handleMessage(Message message) {
switch (message.what) {
case 1000:
this.a.b();
break;
case 1001:
this.a.e();
break;
}
super.handleMessage(message);
}
};
}
}
项目:AppFirCloud
文件:UIProgressResponseListener.java
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case RESPONSE_UPDATE:
UIProgressResponseListener uiProgressResponseListener = mUIProgressResponseListenerWeakReference.get();
if (uiProgressResponseListener != null) {
//获得进度实体类
ProgressModel progressModel = (ProgressModel) msg.obj;
//回调抽象方法
uiProgressResponseListener.onUIResponseProgress(progressModel.getCurrentBytes(), progressModel.getContentLength(), progressModel.isDone());
}
break;
default:
super.handleMessage(msg);
break;
}
}
项目:aos-Video
文件:CastDebug.java
public CastDebug(Context context){
super();
sCastDebug = this;
mContext = context;
mHandler = new android.os.Handler(){
public void handleMessage(Message msg) {
try {
if((ArchosVideoCastManager.getInstance().isRemoteMediaPlaying()||
ArchosVideoCastManager.getInstance().getPlaybackStatus()== MediaStatus.PLAYER_STATE_IDLE)&&is_media_loading){
goToNextVideo();
}
} catch (TransientNetworkDisconnectionException e) {
e.printStackTrace();
} catch (NoConnectionException e) {
e.printStackTrace();
}
}
};
mVideoMapper = new VideoCursorMapper();
ArchosVideoCastManager.getInstance().addArchosCastManagerListener(this);
}
项目:Android_Songshuhui
文件:ContentActivity.java
public void handleMessage(Message msg){
switch (msg.what){
case 1:
response = (String) msg.obj;
//隐藏载入提示
webView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
webView.loadData(response, "text/html;charset=UTF-8", null);//以UTF-8加载HTML代码的内容,防止出现乱码
//以下为对webView的设置
//开启javascript
webView.getSettings().setJavaScriptEnabled(true);
//设置滚动条
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.setHorizontalScrollBarEnabled(false);
//<IMPORTENT!>
//保证webview里图片不会超出当前显示的设置,我也不知道原理,暂时不要更改!
webView.getSettings().setTextZoom(180);
webView.setInitialScale(getScale());
}
}
项目:MapDemo
文件:MainActivity.java
@Override
public void handleMessage(Message msg) {
int type = msg.what;
switch (type) {
case BaiduNaviManager.TTSPlayMsgType.PLAY_START_MSG: {
// showToastMsg("Handler : TTS play start");
break;
}
case BaiduNaviManager.TTSPlayMsgType.PLAY_END_MSG: {
// showToastMsg("Handler : TTS play end");
break;
}
default:
break;
}
}
项目:LifeHelper
文件:CaptureActivityHandler.java
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);
}
项目:miaosou
文件:ComicReadActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comic_read);
Intent intent = getIntent();
comicUrlGet = intent.getStringExtra(ComicFragment.COMICREADURL);
comicUrl = getComicUrl(comicUrlGet);
//pictureId = comicUrl.substring(comicUrl.lastIndexOf("/") + 1,comicUrl.lastIndexOf("."));
//.replace(".html","_2.html");
//Log.d("url",comicUrl);
comicSelectPage = (Button) findViewById(R.id.comic_selectPage);
comicSelectPage.setOnClickListener(this);
tvComicReadPage = (TextView) findViewById(R.id.comic_readPage);
tvComicUrlLines = (TextView) findViewById(R.id.comic_change_lines);
tvComicUrlLines.setOnClickListener(this);
setTVComicUrlLines(tvComicUrlLines);
progressBar = (ProgressBar) findViewById(R.id.pb_comic_progress);
llComicReadBar = (LinearLayout) findViewById(R.id.comic_read_llbar);
comicPagesText = (TextView) findViewById(R.id.read_comic_pages);
viewPager = (ViewPager) findViewById(R.id.comic_read_pager);
//viewPager.setOnLongClickListener(this);
viewPager.setOffscreenPageLimit(1);
pageAdapter = new MyPageAdapter(this.getSupportFragmentManager(), comicViewPagerList);
viewPager.setAdapter(pageAdapter);
viewPager.setPageTransformer(true, new DepthPageTransformer());
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == 1) {
llComicReadBar.setVisibility(View.GONE);
}
}
};
handler.sendEmptyMessageDelayed(1, 3000);
queryComicUrl();
}
项目:AndroidBackendlessChat
文件:TwitterManager.java
private static Message getSuccessMessage(Object listener, Object data){
Message msg = new Message();
msg.what = 1;
msg.arg1 = SUCCESS;
msg.obj = new MessageObj(listener, data);
return msg;
}
项目:UpdateLibrary
文件:HttpClient.java
@Override
public T apply(@NonNull HttpResult<T> tHttpResult) throws Exception {
if (tHttpResult.getStatus() != NetWorkState.SUCCEES) {
Message message = new Message();
message.obj = tHttpResult.getMessage();
handler.sendMessage(message);
throw new ApiException();
}
return tHttpResult.getResult();
}
项目:androidscan
文件:PreviewCallback.java
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
Handler thePreviewHandler = previewHandler;
if (cameraResolution != null && thePreviewHandler != null) {
Message message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
} else {
Log.d(TAG, "Got preview callback, but no handler or resolution available");
}
}
项目:AgentWeb
文件:FileUpLoadChooserImpl.java
@Override
public boolean handleMessage(final Message msg) {
AgentWebUtils.runInUiThread(new Runnable() {
@Override
public void run() {
AboveLCallback.this.safeHandleMessage(msg);
}
});
return false;
}
项目:ChenYan
文件:MyDynnamicActivity.java
@Override
public void handleMessage(Message msg) {
if (msg.what == DynamicAdapter.REPLY_COMMENT) {
DComment comment = (DComment) msg.obj;
int position = msg.arg1;
if (comment.getAuthor().getObjectId().equals(BmobUser.getCurrentUser(User.class).getObjectId())) {
return;
}
showReplyPopup(comment.getDynamicId(), position, comment.getAuthor());
popupInputMethodWindow();
}
}
项目:hanoi-animation
文件:MainActivity.java
@Override
protected Void doInBackground(Integer... params) {
final int totalDisk = params[0];
final CancellationSignal cancellationSignal = new CancellationSignal();
Brain.solveHanoi(totalDisk, new Brain.Callback() {
@Override
public void onMoveDisk(int disk, int from, int to) {
if (isCancelled()) {
cancellationSignal.cancel();
}
Message message = mainUIHandler.obtainMessage(disk, from, to);
mainUIHandler.sendMessageDelayed(message, (++step) * 1000) ;
}
@Override
public void onFinished() {
Log.i(TAG, "Finish solving puzzle in " + step + " steps!");
}
@Override
public void onCanceled() {
Log.i(TAG, "Cancel solving puzzle!");
}
}, cancellationSignal);
return null;
}
项目:UiLib
文件:SuperVideoPlayer.java
@Override
public boolean handleMessage(Message msg) {
if (msg.what == MSG_UPDATE_PLAY_TIME) {
updatePlayTime();
updatePlayProgress();
} else if (msg.what == MSG_HIDE_CONTROLLER) {
showOrHideController();
} else if (msg.what == MSG_PLAY_ON_TV_RESULT) {
shareToTvResult(msg);
} else if (msg.what == MSG_EXIT_FORM_TV_RESULT) {
exitFromTvResult(msg);
}
return false;
}
项目:LQRWeChat
文件:VideoThumbLoader.java
public void handleMessage(Message msg) {
if (imgView.getTag().equals(path)) {
Bitmap btp = (Bitmap) msg.obj;
imgView.setImageBitmap(btp);
}
}
项目:ZxingScanner
文件:DecodeHandler.java
@Override
public void handleMessage(Message message) {
if (!running) {
return;
}
switch (message.what) {
case QRCodeScanner.decode:
decode((byte[]) message.obj, message.arg1, message.arg2);
break;
case QRCodeScanner.quit:
running = false;
Looper.myLooper().quit();
break;
}
}
项目:pay-java-android
文件:Utils.java
static void flushStackLocalLeaks(Looper looper) {
Handler handler = new Handler(looper) {
@Override public void handleMessage(Message msg) {
sendMessageDelayed(obtainMessage(), THREAD_LEAK_CLEANING_MS);
}
};
handler.sendMessageDelayed(handler.obtainMessage(), THREAD_LEAK_CLEANING_MS);
}
项目:mpr121-androidthings
文件:PassiveBuzzerHelper.java
private void playNote(int frequency) {
handler.removeMessages(HANDLER_MSG_STOP);
Message msg = new Message();
msg.what = frequency == 0 ? HANDLER_MSG_STOP : HANDLER_MSG_PLAY;
msg.arg1 = frequency;
handler.sendMessage(msg);
}
项目:androidtools
文件:DatePickerView.java
@Override
public void handleMessage(Message msg) {
if (Math.abs(mMoveLen) < SPEED) {
mMoveLen = 0;
if (mTask != null) {
mTask.cancel();
mTask = null;
performSelect();
}
} else {
// Here, mMoveLen / Math.abs (mMoveLen) is designed to hold the mMoveLen plus or minus sign to achieve roll or roll down.
mMoveLen = mMoveLen - mMoveLen / Math.abs(mMoveLen) * SPEED;
}
invalidate();
}
项目:sealtalk-android-master
文件:AsyncHttpResponseHandler.java
protected Message obtainMessage(int responseMessage, Object response) {
Message msg;
if (handler != null) {
msg = handler.obtainMessage(responseMessage, response);
} else {
msg = Message.obtain();
if (msg != null) {
msg.what = responseMessage;
msg.obj = response;
}
}
return msg;
}
项目:AndroidProgramming3e
文件:ThumbnailDownloader.java
@Override
protected void onLooperPrepared() {
mRequestHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == MESSAGE_DOWNLOAD) {
T target = (T) msg.obj;
Log.i(TAG, "Got a request for URL: " + mRequestMap.get(target));
handleRequest(target);
}
}
};
}
项目:microbit
文件:PluginService.java
/**
* Handler of incoming messages from BLEListener.
*/
private void handleMicroBitMessage(Message msg) {
Bundle data = msg.getData();
CmdArg cmd = new CmdArg(data.getInt(IPCConstants.BUNDLE_DATA), data.getString(IPCConstants.BUNDLE_VALUE));
logi("handleMicrobitMessage() ## msg.arg1 = " + msg.arg1 + " ## data.getInt=" + data.getInt(IPCConstants
.BUNDLE_DATA) + " ## data.getString=" + data.getString(IPCConstants.BUNDLE_VALUE));
AbstractPlugin abstractPlugin = pluginsCreator.createPlugin(msg.arg1, pluginHandler);
if(abstractPlugin != null) {
abstractPlugin.handleEntry(cmd);
}
}
项目:popomusic
文件:MainActivty.java
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
mServiceMessenger = new Messenger(iBinder);
//连接到服务
if (null != mServiceMessenger) {
Message msgToService = Message.obtain();
msgToService.replyTo = mMessengerClient;
msgToService.what = Constant.MAIN_ACTIVITY;
try {
mServiceMessenger.send(msgToService);
} catch (RemoteException e) {
e.printStackTrace();
}
}
}