Java Code Examples for android.os.Message
The following are top voted examples for showing how to use
android.os.Message. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to generate
more good examples.
Example 1
Project: iconsole-android File: BluetoothChatService.java View source code | 9 votes |
/** * 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(); }
Example 2
Project: xmrwallet File: WalletService.java View source code | 9 votes |
@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; } }
Example 3
Project: container File: VPackageInstallerService.java View source code | 9 votes |
@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(); }
Example 4
Project: boohee_v5.6 File: LEYUApplication.java View source code | 6 votes |
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); } }
Example 5
Project: GitHub File: QueuesHandler.java View source code | 6 votes |
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); }
Example 6
Project: 3DPrint-Controller File: ModelInfoPopupWindow.java View source code | 6 votes |
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(); }
Example 7
Project: 19porn File: PersonInfoActivity.java View source code | 6 votes |
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(); }
Example 8
Project: GitHub File: OkBus.java View source code | 6 votes |
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; }
Example 9
Project: live_master File: GiraffePlayer.java View source code | 6 votes |
@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; } }
Example 10
Project: OpenVideoCall-Android File: WorkerThread.java View source code | 6 votes |
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(); } }
Example 11
Project: Hotspot-master-devp File: UIProgressRequestListener.java View source code | 6 votes |
@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; } }
Example 12
Project: TPlayer File: InitActivity.java View source code | 6 votes |
@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; } }
Example 13
Project: TPlayer File: MediaPlayer.java View source code | 6 votes |
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); } }
Example 14
Project: XPrivacy File: XActivityThread.java View source code | 6 votes |
@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()); }
Example 15
Project: Hitalk File: HitalkMonitor.java View source code | 6 votes |
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; } } }; }
Example 16
Project: -Pod File: MusicFragment.java View source code | 6 votes |
@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); }
Example 17
Project: Aurora File: DownloadSerialQueue.java View source code | 6 votes |
@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; }
Example 18
Project: letv File: g.java View source code | 6 votes |
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); } }; } }
Example 19
Project: AppFirCloud File: UIProgressResponseListener.java View source code | 6 votes |
@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; } }
Example 20
Project: aos-Video File: CastDebug.java View source code | 6 votes |
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); }
Example 21
Project: Android_Songshuhui File: ContentActivity.java View source code | 6 votes |
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()); } }
Example 22
Project: MapDemo File: MainActivity.java View source code | 6 votes |
@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; } }
Example 23
Project: LifeHelper File: CaptureActivityHandler.java View source code | 6 votes |
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); }
Example 24
Project: miaosou File: ComicReadActivity.java View source code | 5 votes |
@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(); }
Example 25
Project: AndroidBackendlessChat File: TwitterManager.java View source code | 5 votes |
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; }
Example 26
Project: UpdateLibrary File: HttpClient.java View source code | 5 votes |
@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(); }
Example 27
Project: androidscan File: PreviewCallback.java View source code | 5 votes |
@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"); } }
Example 28
Project: AgentWeb File: FileUpLoadChooserImpl.java View source code | 5 votes |
@Override public boolean handleMessage(final Message msg) { AgentWebUtils.runInUiThread(new Runnable() { @Override public void run() { AboveLCallback.this.safeHandleMessage(msg); } }); return false; }
Example 29
Project: ChenYan File: MyDynnamicActivity.java View source code | 5 votes |
@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(); } }
Example 30
Project: hanoi-animation File: MainActivity.java View source code | 5 votes |
@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; }
Example 31
Project: UiLib File: SuperVideoPlayer.java View source code | 5 votes |
@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; }
Example 32
Project: LQRWeChat File: VideoThumbLoader.java View source code | 5 votes |
public void handleMessage(Message msg) { if (imgView.getTag().equals(path)) { Bitmap btp = (Bitmap) msg.obj; imgView.setImageBitmap(btp); } }
Example 33
Project: ZxingScanner File: DecodeHandler.java View source code | 5 votes |
@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; } }
Example 34
Project: pay-java-android File: Utils.java View source code | 5 votes |
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); }
Example 35
Project: mpr121-androidthings File: PassiveBuzzerHelper.java View source code | 5 votes |
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); }
Example 36
Project: androidtools File: DatePickerView.java View source code | 5 votes |
@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(); }
Example 37
Project: sealtalk-android-master File: AsyncHttpResponseHandler.java View source code | 5 votes |
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; }
Example 38
Project: AndroidProgramming3e File: ThumbnailDownloader.java View source code | 5 votes |
@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); } } }; }
Example 39
Project: microbit File: PluginService.java View source code | 5 votes |
/** * 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); } }
Example 40
Project: popomusic File: MainActivty.java View source code | 5 votes |
@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(); } } }