List of usage examples for android.os Message sendToTarget
public void sendToTarget()
From source file:ti.modules.titanium.geolocation.TiLocation.java
public void forwardGeocode(String address, GeocodeResponseHandler responseHandler) { if (address != null) { String geocoderUrl = buildGeocoderURL(TiC.PROPERTY_FORWARD, mobileId, appGuid, sessionId, address, countryCode);/*ww w. ja v a 2s.c om*/ if (geocoderUrl != null) { Message message = runtimeHandler.obtainMessage(MSG_LOOKUP); message.getData().putString(TiC.PROPERTY_DIRECTION, TiC.PROPERTY_FORWARD); message.getData().putString(TiC.PROPERTY_URL, geocoderUrl); message.obj = responseHandler; message.sendToTarget(); } } else { Log.e(TAG, "Unable to forward geocode, address is null"); } }
From source file:com.applozic.mobicomkit.api.attachment.AttachmentManager.java
/** * Handles state messages for a particular task object * * @param photoTask A task object/*from w w w .ja v a 2 s .c om*/ * @param state The state of the task */ @SuppressLint("HandlerLeak") public void handleState(AttachmentTask photoTask, int state) { switch (state) { // The task finished downloading and decoding the image case TASK_COMPLETE: // Puts the image into cache if (photoTask.isCacheEnabled()) { // If the task is set to cache the results, put the buffer // that was // successfully decoded into the cache if (photoTask != null && photoTask.getImage() != null) { mPhotoCache.put(photoTask.getMessage().getKeyString(), photoTask.getImage()); } } // Gets a Message object, stores the state in it, and sends it to the Handler Message completeMessage = mHandler.obtainMessage(state, photoTask); completeMessage.sendToTarget(); break; // The task finished downloading the image case DOWNLOAD_COMPLETE: /* * If it is a image than decodes the image, by queuing the decoder object to run in the decoder * */ if (photoTask.getPhotoView() != null && photoTask.getContentType() != null && photoTask.getContentType().contains("image")) { mDecodeThreadPool.execute(photoTask.getPhotoDecodeRunnable()); } else { //We need not to cache the Data here ..as we have nothing to load // ...directly sending TASK complete message is enough mHandler.obtainMessage(TASK_COMPLETE, photoTask).sendToTarget(); } // In all other cases, pass along the message without any other action. default: mHandler.obtainMessage(state, photoTask).sendToTarget(); break; } }
From source file:com.tencent.wstt.gt.activity.GTParamOutFragment.java
@Override public void onClick(View v) { Message msg = opHandler.obtainMessage(); switch (v.getId()) { case R.id.btn_monitor: msg.what = 0; // ?gw msg.sendToTarget(); break;//ww w. j a v a 2s. c o m case R.id.btn_monitor_stop: // ?gw msg.what = 1; msg.sendToTarget(); break; case R.id.gwdata_delete: // ? msg.what = 2; msg.sendToTarget(); break; case R.id.gwdata_save: // ?? msg.what = 3; msg.sendToTarget(); break; } }
From source file:com.android.camera.manager.ThumbnailViewManager.java
private void sendUpdateThumbnail() { Log.d(TAG, "[sendUpdateThumbnail]..."); mIsUpdatingThumbnail = true;// ww w . j a v a 2s . c om mMainHandler.removeMessages(MSG_UPDATE_THUMBNAIL); Message msg = mMainHandler.obtainMessage(MSG_UPDATE_THUMBNAIL, mThumbnail); msg.sendToTarget(); }
From source file:most.voip.example.ws_config.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_quit: if (this.voipHandler != null) { Message m = Message.obtain(this.voipHandler, -1); m.sendToTarget(); break; } else {/*from ww w. j a va 2 s . c o m*/ Log.d(TAG, "Exiting app"); finish(); Runtime.getRuntime().gc(); android.os.Process.killProcess(android.os.Process.myPid()); } default: break; } return true; }
From source file:ti.modules.titanium.geolocation.GeolocationModule.java
@Kroll.method public void reverseGeocoder(double latitude, double longitude, KrollCallback callback) { String mid = TiPlatformHelper.getMobileId(); String aguid = getTiContext().getTiApp().getAppInfo().getGUID(); String sid = TiPlatformHelper.getSessionId(); String countryCode = Locale.getDefault().getCountry(); String url = buildGeoURL("r", mid, aguid, sid, latitude + "," + longitude, countryCode); if (url != null) { Message msg = getUIHandler().obtainMessage(MSG_LOOKUP); msg.getData().putString("direction", "r"); msg.getData().putString("url", url); msg.obj = callback;//w w w . j a va 2 s .c o m msg.sendToTarget(); } }
From source file:ti.modules.titanium.geolocation.GeolocationModule.java
@Kroll.method public void forwardGeocoder(String address, KrollCallback listener) { if (address != null) { String mid = TiPlatformHelper.getMobileId(); String aguid = getTiContext().getTiApp().getAppInfo().getGUID(); String sid = TiPlatformHelper.getSessionId(); String countryCode = Locale.getDefault().getCountry(); String url = buildGeoURL("f", mid, aguid, sid, address, countryCode); if (url != null) { Message msg = getUIHandler().obtainMessage(MSG_LOOKUP); msg.getData().putString("direction", "f"); msg.getData().putString("url", url); msg.obj = listener;//from w w w . j a va2s. c o m msg.sendToTarget(); } } else { Log.w(LCAT, "Address should not be null."); } }
From source file:cn.edu.sdnu.i.util.xauth.Xauth.java
@Override public void run() { Message message; if (flag) {/*from ww w.j av a2 s . c o m*/ doAccessToken(); //??. flag = false; } String result = doMethod(this.urlGlobal); if (result.length() > 0) { message = this.mHanlerGlobal.obtainMessage(1, result); } else { message = this.mHanlerGlobal.obtainMessage(0, result); } message.sendToTarget(); }
From source file:de.frank_durr.ble_v_monitor.HistoryFragment.java
/** * Trigger an update of the corresponding history of the data model by querying the GATT server. * All interaction with the GATT server is done by the main activity, thus, we need * to send a message to the main activity to trigger the update. After the data model * has been updated, this fragment will receive a notification via the * update notification handler.//from w w w . java 2 s. c om */ private void triggerHistoryUpdate() { if (activity.updateTriggerHandler != null) { Message msg = activity.updateTriggerHandler.obtainMessage(); switch (historyType) { case minutely: msg.arg1 = MainActivity.UPDATE_MINUTELY_HISTORY; break; case hourly: msg.arg1 = MainActivity.UPDATE_HOURLY_HISTORY; break; case daily: msg.arg1 = MainActivity.UPDATE_DAILY_HISTORY; break; } msg.sendToTarget(); } }
From source file:com.hang.exoplayer.PlayService.java
public void play() { Message message = playHandler.obtainMessage(); message.what = 1;// w w w . j a v a 2 s. com int playType = Util.TYPE_HLS; if (playAddresses.get(mCurrentPosition).startsWith("file://")) { playType = Util.TYPE_OTHER; } Samples.Sample sample = new Samples.Sample("", playAddresses.get(mCurrentPosition), playType); message.obj = sample; message.sendToTarget(); requestFocus(); }