List of usage examples for android.os Message setData
public void setData(Bundle data)
From source file:com.hartcode.hartweather.list.WeatherListActivity.java
@Override public void onNetworkError(String error) { Message msg = new Message(); Bundle bundle = new Bundle(); bundle.putString(getString(R.string.network_error_key), error); msg.setData(bundle); msg.what = 1;/*from w w w . j a va 2 s .c o m*/ this.networkDataChangeHandler.sendMessage(msg); }
From source file:org.sufficientlysecure.keychain.ui.dialog.AddEditSmartPGPAuthorityDialogFragment.java
/** * Send message back to handler which is initialized in a activity * *//*from ww w . ja v a 2 s . co m*/ private void sendMessageToHandler(Bundle data) { Message msg = Message.obtain(); if (data != null) { msg.setData(data); } try { mMessenger.send(msg); } catch (RemoteException e) { Log.w(Constants.TAG, "Exception sending message, Is handler present?", e); } catch (NullPointerException e) { Log.w(Constants.TAG, "Messenger is null!", e); } }
From source file:com.tenkiv.tekdaqc.android.services.CommunicationService.java
@Override public void onDestroy() { // Send shutdown action Bundle extras = new Bundle(); extras.putString(TekCast.EXTRA_SERVICE_ACTION, ServiceAction.STOP.name()); final Message msg = mServiceHandler.obtainMessage(); msg.setData(extras); mServiceHandler.sendMessage(msg);// w w w.j a va 2 s. co m super.onDestroy(); }
From source file:com.hartcode.hartweather.list.WeatherListActivity.java
@Override public void onNetworkQueueChange(boolean isEmpty) { Message msg = new Message(); Bundle bundle = new Bundle(); bundle.putBoolean(getString(R.string.network_is_empty_key), isEmpty); msg.setData(bundle); msg.what = 0;//from w w w . j a v a2 s . com this.networkDataChangeHandler.sendMessage(msg); }
From source file:com.nextgis.firereporter.ScanexHttpLogin.java
@Override protected Void doInBackground(String... urls) { if (HttpGetter.IsNetworkAvailible(mContext)) { String sUser = urls[0];// w w w . ja v a 2 s. c o m String sPass = urls[1]; try { // Create a new HttpClient HttpClient httpclient = new DefaultHttpClient(); // step 1. open login dialog String sRedirect = "http://fires.kosmosnimki.ru/SAPI/oAuthCallback.html&authServer=MyKosmosnimki"; String sURL = "http://fires.kosmosnimki.ru/SAPI/LoginDialog.ashx?redirect_uri=" + Uri.encode(sRedirect); HttpGet httpget = new HttpGet(sURL); HttpParams params = httpget.getParams(); params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE); httpget.setParams(params); HttpResponse response = httpclient.execute(httpget); //2 get cookie and params Header head = response.getFirstHeader("Set-Cookie"); String sCookie = head.getValue(); head = response.getFirstHeader("Location"); String sLoc = head.getValue(); Uri uri = Uri.parse(sLoc); String sClientId = uri.getQueryParameter("client_id"); String sScope = uri.getQueryParameter("scope"); String sState = uri.getQueryParameter("state"); String sPostUri = "http://my.kosmosnimki.ru/Account/LoginDialog?redirect_uri=" + Uri.encode(sRedirect) + "&client_id=" + sClientId + "&scope=" + sScope + "&state=" + sState; HttpPost httppost = new HttpPost(sPostUri); params = httppost.getParams(); params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE); httppost.setHeader("Cookie", sCookie); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("email", sUser)); nameValuePairs.add(new BasicNameValuePair("password", sPass)); nameValuePairs.add(new BasicNameValuePair("IsApproved", "true")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); response = httpclient.execute(httppost); head = response.getFirstHeader("Set-Cookie"); if (head == null) { mError = mContext.getString(R.string.noNetwork); return null; } sCookie += "; " + head.getValue(); head = response.getFirstHeader("Location"); sLoc = head.getValue(); uri = Uri.parse(sLoc); String sCode = uri.getQueryParameter("code"); sState = uri.getQueryParameter("state"); //3 get String sGetUri = "http://fires.kosmosnimki.ru/SAPI/Account/logon/?authServer=MyKosmosnimki&code=" + sCode + "&state=" + sState; httpget = new HttpGet(sGetUri); httpget.setHeader("Cookie", sCookie); params = httpget.getParams(); params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE); httpget.setParams(params); response = httpclient.execute(httpget); head = response.getFirstHeader("Set-Cookie"); if (head == null) { mError = mContext.getString(R.string.noNetwork); return null; } sCookie += "; " + head.getValue(); Bundle bundle = new Bundle(); if (sCookie.length() > 0) { //if(bGetCookie){ bundle.putBoolean(GetFiresService.ERROR, false); bundle.putString(GetFiresService.JSON, sCookie); //bundle.putString("json", mContent); } else { bundle.putBoolean(GetFiresService.ERROR, true); } bundle.putInt(GetFiresService.SOURCE, mnType); Message msg = new Message(); msg.setData(bundle); if (mEventReceiver != null) { mEventReceiver.sendMessage(msg); } } catch (ClientProtocolException e) { mError = e.getMessage(); return null; } catch (IOException e) { mError = e.getMessage(); return null; } catch (Exception e) { mError = e.getMessage(); return null; } } else { Bundle bundle = new Bundle(); bundle.putBoolean(GetFiresService.ERROR, true); bundle.putString(GetFiresService.ERR_MSG, mContext.getString(R.string.noNetwork)); bundle.putInt(GetFiresService.SOURCE, mnType); Message msg = new Message(); msg.setData(bundle); if (mEventReceiver != null) { mEventReceiver.sendMessage(msg); } } return null; }
From source file:io.github.importre.android.chromeadb.ChromeAdbService.java
private void moveCursor(String coords) { try {//from w w w . j ava 2s.c o m final String[] points = coords.split(","); for (int i = 0; i < points.length; i += 2) { int x = Integer.parseInt(points[i]); int y = Integer.parseInt(points[i + 1]); Message msg = mHandler.obtainMessage(); Bundle data = new Bundle(); data.putInt("x", x); data.putInt("y", y); msg.setData(data); mHandler.sendMessage(msg); } } catch (Exception e) { } }
From source file:com.tweetlanes.android.service.BackgroundService.java
private void sendMessageToUI(int intvaluetosend) { for (int i = mClients.size() - 1; i >= 0; i--) { try {// w w w. j a va 2s . c om // Send data as an Integer mClients.get(i).send(Message.obtain(null, MSG_SET_INT_VALUE, intvaluetosend, 0)); //Send data as a String Bundle b = new Bundle(); b.putString("str1", "ab" + intvaluetosend + "cd"); Message msg = Message.obtain(null, MSG_SET_STRING_VALUE); msg.setData(b); mClients.get(i).send(msg); } catch (RemoteException e) { // The client is dead. Remove it from the list; we are going through the list from back to front so this is safe to do inside the loop. mClients.remove(i); } } }
From source file:mobi.espier.lgc.LgcApp.java
public void onNotification(CharSequence packageName, Notification notification, long time) { Message message = mHandler.obtainMessage(MSG_ON_NOTIFICATION); Bundle data = new Bundle(); data.putCharSequence(KEY_PACKAGE_NAME, packageName); data.putParcelable(KEY_NOTIFICATION, notification); data.putLong(KEY_NOTIFICATION_TIME, time); message.setData(data); mHandler.sendMessage(message);/*from w w w . ja v a 2 s . c om*/ }
From source file:org.egov.android.controller.ServiceController.java
/** * After binding the service, we can send message to the service to start/stop running * background jobs./*from ww w . j a v a2 s . c o m*/ * * @param action * => START, STOP * @param b * => bundle data to be send */ public void sendMessageToService(int action, Bundle b) { if (isBound && myService != null) { try { Message msg = Message.obtain(null, action); msg.setData(b); myService.send(msg); } catch (RemoteException e) { e.printStackTrace(); } } }
From source file:org.zywx.wbpalmstar.plugin.uexCalendarView.EUExCalendarView.java
private void sendMessageInProgress(int msgType, String[] params) { if (mHandler == null) { return;/*from ww w . j a v a2 s . com*/ } Message msg = Message.obtain(); msg.what = msgType; msg.obj = this; Bundle b = new Bundle(); b.putStringArray(ECalendarViewUtils.CALENDAR_PARAMS_KEY_FUNCTION, params); msg.setData(b); mHandler.sendMessage(msg); }