List of usage examples for android.os Message obtain
public static Message obtain()
From source file:com.ratebeer.android.gui.components.PosterService.java
private void callbackMessenger(Intent intent, int result) { if (intent.hasExtra(EXTRA_MESSENGER)) { // Prepare a message Messenger callback = intent.getParcelableExtra(EXTRA_MESSENGER); Message msg = Message.obtain(); msg.arg1 = result;/*from www. j a v a 2s . c o m*/ try { // Send it back to the messenger, i.e. the activity callback.send(msg); } catch (RemoteException e) { Log.e(com.ratebeer.android.gui.components.helpers.Log.LOG_NAME, "Cannot call back to activity to deliver message '" + msg.toString() + "'"); } } }
From source file:com.droid.app.fotobot.FotoBot.java
/** * ? ?/*w w w . j av a 2 s.co m*/ * * @param str ? ?? * @param status ?? ?? */ public void SendMessage(String str, String status) { Message msg = Message.obtain(); // Creates an new Message instance msg.obj = str; // Put the string into Message, into "obj" field. msg_status = status; msg.setTarget(h); // Set the Handler msg.sendToTarget(); //Send the message }
From source file:com.hxqc.mall.auto.fragment.CenterEditAutoFragment.java
/** * ?//from w ww .j a va 2 s .co m * * @param brand * @param brandID * @param brandThumb * @param series * @param seriesID * @param model * @param modelID */ public void setAutoType(String brand, String brandID, String brandThumb, String seriesBrandName, String series, String seriesID, String model, String modelID) { Message msg = Message.obtain(); msg.what = AutoInfoContants.AUTO_TYPE_BACK_DATA; mMyAuto.brand = brand; mMyAuto.brandID = brandID; mMyAuto.brandThumb = brandThumb; mMyAuto.series = series; mMyAuto.seriesID = seriesID; mMyAuto.autoModel = model; mMyAuto.autoModelID = modelID; mMyAuto.brandName = seriesBrandName; msg.obj = mMyAuto; mHandler.sendMessage(msg); }
From source file:website.openeng.anki.DeckPicker.java
@Override protected void onCollectionLoaded(Collection col) { // keep reference to collection in parent super.onCollectionLoaded(col); // create backup in background if needed Boolean started = BackupManager.performBackupInBackground(col.getPath()); if (started) { // Themes.showThemedToast(this, getResources().getString(R.string.backup_collection), true); }//from w w w . j av a 2 s . c o m // Force a full sync if flag was set in upgrade path, asking the user to confirm if necessary if (mRecommendFullSync) { mRecommendFullSync = false; try { col.modSchema(); } catch (ConfirmModSchemaException e) { // If libanki determines it's necessary to confirm the full sync then show a confirmation dialog // We have to show the dialog via the DialogHandler since this method is called via a Loader Resources res = getResources(); Message handlerMessage = Message.obtain(); handlerMessage.what = DialogHandler.MSG_SHOW_FORCE_FULL_SYNC_DIALOG; Bundle handlerMessageData = new Bundle(); handlerMessageData.putString("message", res.getString(R.string.full_sync_confirmation_upgrade) + "\n\n" + res.getString(R.string.full_sync_confirmation)); handlerMessage.setData(handlerMessageData); getDialogHandler().sendMessage(handlerMessage); } } // prepare deck counts and mini-today-statistic updateDeckList(); // Open StudyOptionsFragment if in fragmented mode if (mFragmented) { // Create the fragment in a new handler since Android won't let you perform fragment // transactions in a loader's onLoadFinished. new Handler().post(new Runnable() { public void run() { loadStudyOptionsFragment(false); } }); } hideProgressBar(); automaticSync(); }
From source file:ro.ciubex.keepscreenlock.MainApplication.java
/** * Send a message to service.//from w w w. j ava2 s. c o m */ public void sendToKeepScreenLockService(String messageKey, String messageValue) { if (mBound) { Message msg = Message.obtain(); Bundle bundle = new Bundle(); bundle.putString(messageKey, messageValue); msg.setData(bundle); try { mService.send(msg); } catch (RemoteException e) { logE(TAG, "sendMessageToService(" + messageKey + "," + messageValue + "): " + e.getMessage(), e); } } }
From source file:com.ichi2.anki.DeckPicker.java
/** * Perform the following tasks:/*from w ww .j av a 2 s. com*/ * Automatic backup * loadStudyOptionsFragment() if tablet * Automatic sync */ private void onFinishedStartup() { // create backup in background if needed BackupManager.performBackupInBackground(getCol().getPath()); // Force a full sync if flag was set in upgrade path, asking the user to confirm if necessary if (mRecommendFullSync) { mRecommendFullSync = false; try { getCol().modSchema(); } catch (ConfirmModSchemaException e) { // If libanki determines it's necessary to confirm the full sync then show a confirmation dialog // We have to show the dialog via the DialogHandler since this method is called via a Loader Resources res = getResources(); Message handlerMessage = Message.obtain(); handlerMessage.what = DialogHandler.MSG_SHOW_FORCE_FULL_SYNC_DIALOG; Bundle handlerMessageData = new Bundle(); handlerMessageData.putString("message", res.getString(R.string.full_sync_confirmation_upgrade) + "\n\n" + res.getString(R.string.full_sync_confirmation)); handlerMessage.setData(handlerMessageData); getDialogHandler().sendMessage(handlerMessage); } } // Open StudyOptionsFragment if in fragmented mode if (mFragmented) { loadStudyOptionsFragment(false); } automaticSync(); }
From source file:com.taobao.weex.ui.component.WXComponent.java
/** * Add new event to component,this will post a task to DOM thread to add event. * @param type//from w w w.j a va 2 s. co m */ protected void appendEventToDOM(String type) { Message message = Message.obtain(); WXDomTask task = new WXDomTask(); task.instanceId = getInstanceId(); task.args = new ArrayList<>(); task.args.add(getRef()); task.args.add(type); message.obj = task; message.what = WXDomHandler.MsgType.WX_DOM_ADD_EVENT; WXSDKManager.getInstance().getWXDomManager().sendMessage(message); }
From source file:cn.xiaocool.android_etong.net.constant.request.MainRequest.java
public void GetGoodsComments(final String goodsid) { new Thread() { Message msg = Message.obtain(); @Override//from w w w .ja v a 2s. c o m public void run() { String data = "&goodsid=" + goodsid; Log.e("data=", data); String result_data = NetUtil.getResponse(WebAddress.GetGoodsComments, data); Log.e("result_data=", result_data); try { JSONObject jsonObject = new JSONObject(result_data); msg.what = CommunalInterfaces.GetGoodsComments; msg.obj = jsonObject; } catch (JSONException e) { e.printStackTrace(); } finally { handler.sendMessage(msg); } } }.start(); }
From source file:cn.xiaocool.android_etong.net.constant.request.MainRequest.java
public void GetGoodPropertyList(final String type) { new Thread() { Message msg = Message.obtain(); @Override/* www . j a va2 s. c om*/ public void run() { String data = "&goodstype=" + type; Log.e("data=", data); String result_data = NetUtil.getResponse(WebAddress.GetGoodPropertyList, data); Log.e("result_data=", result_data); try { JSONObject jsonObject = new JSONObject(result_data); msg.what = CommunalInterfaces.GetGoodPropertyList; msg.obj = jsonObject; } catch (JSONException e) { e.printStackTrace(); } finally { handler.sendMessage(msg); } } }.start(); }
From source file:cn.xiaocool.android_etong.net.constant.request.MainRequest.java
public void AddGoodsProperty(final String goodsid, final String type, final String propertylist) { new Thread() { Message msg = Message.obtain(); @Override/*w w w. ja v a 2s. c om*/ public void run() { String data = "&goodsid=" + goodsid + "&type=" + type + "&propertylist=" + propertylist; Log.e("data=", data); String result_data = NetUtil.getResponse(WebAddress.AddGoodsProperty, data); Log.e("result_data=", result_data); try { JSONObject jsonObject = new JSONObject(result_data); msg.what = CommunalInterfaces.AddGoodsProperty; msg.obj = jsonObject; } catch (JSONException e) { e.printStackTrace(); } finally { handler.sendMessage(msg); } } }.start(); }