List of usage examples for android.os Messenger Messenger
public Messenger(IBinder target)
From source file:com.shinymetal.gradereport.AbstractActivity.java
public void doBindService() { Intent intent = null;//from w w w . j a v a2 s. co m intent = new Intent(this, DiaryUpdateService.class); // Create a new Messenger for the communication back // From the Service to the Activity Messenger messenger = new Messenger(mHandler); intent.putExtra("MESSENGER", messenger); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); }
From source file:com.first3.viz.download.DownloadManager.java
@Override public void onCreate() { Log.d();/*from w w w .ja v a2 s .co m*/ mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Start up the thread running the service. Note that we create // a separate thread because the service normally runs in the process's // main thread, which we don't want to block. We also make it background // priority so CPU-intensive work will not disrupt our UI. //HandlerThread thread = new HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND); //thread.start(); mIncomingHandler = new IncomingHandler(); mMessenger = new Messenger(mIncomingHandler); }
From source file:com.darshancomputing.BatteryIndicatorPro.BatteryInfoService.java
@Override public void onCreate() { res = getResources();/*from ww w.j av a 2 s .c o m*/ str = new Str(res); log_db = new LogDatabase(this); info = new BatteryInfo(); messenger = new Messenger(new MessageHandler()); clientMessengers = new java.util.HashSet<Messenger>(); predictor = new Predictor(this); bl = BatteryLevel.getInstance(this, BatteryLevel.SIZE_NOTIFICATION); cwbg = new CircleWidgetBackground(this); alarms = new AlarmDatabase(this); mNotificationManager = NotificationManagerCompat.from(this); mainNotificationB = new NotificationCompat.Builder(this); alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); loadSettingsFiles(); sdkVersioning(); currentHack = CurrentHack.getInstance(this); currentHack.setPreferFS(settings.getBoolean(SettingsActivity.KEY_CURRENT_HACK_PREFER_FS, res.getBoolean(R.bool.default_prefer_fs_current_hack))); Intent currentInfoIntent = new Intent(this, BatteryInfoActivity.class).putExtra(EXTRA_CURRENT_INFO, true); currentInfoPendingIntent = PendingIntent.getActivity(this, RC_MAIN, currentInfoIntent, 0); Intent updatePredictorIntent = new Intent(this, BatteryInfoService.class); updatePredictorIntent.putExtra(EXTRA_UPDATE_PREDICTOR, true); updatePredictorPendingIntent = PendingIntent.getService(this, 0, updatePredictorIntent, 0); Intent alarmsIntent = new Intent(this, BatteryInfoActivity.class).putExtra(EXTRA_EDIT_ALARMS, true); alarmsPendingIntent = PendingIntent.getActivity(this, RC_ALARMS, alarmsIntent, 0); widgetManager = AppWidgetManager.getInstance(this); Class[] appWidgetProviders = { BatteryInfoAppWidgetProvider.class, /* Circle widget! */ FullAppWidgetProvider.class }; for (int i = 0; i < appWidgetProviders.length; i++) { int[] ids = widgetManager.getAppWidgetIds(new ComponentName(this, appWidgetProviders[i])); for (int j = 0; j < ids.length; j++) { widgetIds.add(ids[j]); } } Intent bc_intent = registerReceiver(mBatteryInfoReceiver, batteryChanged); info.load(bc_intent, sp_service); }
From source file:android.support.v7.media.MediaRouteProviderService.java
/** * Creates a media route provider service. *//*from w w w . j av a 2 s . c om*/ public MediaRouteProviderService() { mReceiveHandler = new ReceiveHandler(this); mReceiveMessenger = new Messenger(mReceiveHandler); mPrivateHandler = new PrivateHandler(); mProviderCallback = new ProviderCallback(); }
From source file:org.anhonesteffort.flock.ImportOwsAccountFragment.java
private void handleImportAccountAsync() { if (messageHandler != null && messageHandler.serviceStarted) return;/*w ww.ja v a2 s .c om*/ else if (messageHandler == null) messageHandler = new MessageHandler(setupActivity, this); Bundle result = new Bundle(); String accountId = ((TextView) getView().findViewById(R.id.account_username)).getText().toString().trim(); String cipherPassphrase = ((TextView) getView().findViewById(R.id.cipher_passphrase)).getText().toString() .trim(); if (StringUtils.isEmpty(accountId)) { result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_EMPTY_ACCOUNT_ID); ErrorToaster.handleDisplayToastBundledError(getActivity(), result); ((TextView) getView().findViewById(R.id.account_username)).setText(""); ((TextView) getView().findViewById(R.id.cipher_passphrase)).setText(""); return; } if (cipherPassphrase.length() == 0) { result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_SHORT_PASSWORD); ErrorToaster.handleDisplayToastBundledError(getActivity(), result); ((TextView) getView().findViewById(R.id.account_username)).setText(""); ((TextView) getView().findViewById(R.id.cipher_passphrase)).setText(""); return; } Intent importService = new Intent(getActivity(), ImportOwsAccountService.class); accountId = DavAccountHelper.correctUsername(getActivity(), accountId); importService.putExtra(ImportOwsAccountService.KEY_MESSENGER, new Messenger(messageHandler)); importService.putExtra(ImportOwsAccountService.KEY_ACCOUNT_ID, accountId); importService.putExtra(ImportOwsAccountService.KEY_MASTER_PASSPHRASE, cipherPassphrase); getActivity().startService(importService); messageHandler.serviceStarted = true; setupActivity.setNavigationDisabled(true); getActivity().setProgressBarIndeterminateVisibility(true); getActivity().setProgressBarVisibility(true); }
From source file:com.google.android.DemoKit.DemoKitActivity.java
/** Called when the activity is first created. */ @Override// w w w . j a va 2 s. c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = getApplicationContext(); // Toast.makeText(this, "inside onCreate of DemoKitActivity", Toast.LENGTH_SHORT).show(); IntentFilter connFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); mConnReceiver = new ConnBroadcastReceiver(); registerReceiver(mConnReceiver, connFilter); setContentView(R.layout.main); enableControls(true); mNocServiceRequestor = new PeriodicScheduler(new Runnable() { @Override public void run() { if (mNocAccessServiceMessenger != null) { toastHandler("Trying to upload Sensor Data"); // if(mConnReceiver.isConnected) { Message msg = Message.obtain(null, NocMessages.URL_MSG, 0, 0); Bundle msgBundle = new Bundle(); msgBundle.putString("url", "http://98.26.23.101/update.php?req=UI:WLDCTLAB1;FV:1.36;E1:0;EC1:0;E2:0;EC2:0;FL:2937;FC:0;BA:1218;TO:2181;TC:2181;FL20:0;FE:0;BL:0;HTO:0;HTC:0;BP1:0;BP2:0;GF:0;UF:1;IN:0;DT:0;TCF:0;TOF:0"); msg.setData(msgBundle); try { mNocAccessServiceMessenger.send(msg); } catch (RemoteException e) { } } else { toastHandler("mNocAccessServiceMessenger is null!"); } } }, 5000); mBTMsgHandler = new Messenger(new BluetoothMsgHandler()); mAccessoryMsgHandler = new Messenger(new ServiceMsgHandler()); mNocMsgHandler = new Messenger(new ServiceMsgHandler()); }
From source file:fr.julienvermet.bugdroid.ui.tablet.BugMultiPaneActivity.java
public void loadBug(boolean fromCache) { if (mRefreshMenu != null) { mRefreshMenu.setVisible(false);/*from w w w . jav a 2s . c om*/ } setSupportProgressBarIndeterminateVisibility(true); Intent intent = BugIntentService.getIntent(this, mInstance, mBugId, fromCache); Messenger messenger = new Messenger(onBugReceivedHandler); intent.putExtra(BugIntentService.MESSENGER, messenger); startService(intent); }
From source file:io.n7.calendar.caldav.CalDAVService.java
@Override public void onCreate() { mCR = getContentResolver();/*from w w w . j av a2s .com*/ // Check if there are any CalDAV accounts setup. // Check if the CalDAV calendars are present in the provider DB. If not, create. // Start Sync for all CalDAV calendars. mContext = this; HandlerThread thread = new HandlerThread("CalDAVService", Process.THREAD_PRIORITY_BACKGROUND); thread.start(); mServiceLooper = thread.getLooper(); mServiceHandler = new IncomingHandler(mServiceLooper); mMessenger = new Messenger(mServiceHandler); }
From source file:com.googlecode.networklog.NetworkLog.java
void doBindService() { MyLog.d("doBindService"); if (isBound) { MyLog.d("Already bound to service; unbinding..."); doUnbindService();/*from w w w.jav a 2 s. co m*/ } messenger = new Messenger(new IncomingHandler()); MyLog.d("Created messenger: " + messenger); MyLog.d("Binding connection to service: " + connection); bindService(new Intent(this, NetworkLogService.class), connection, 0); MyLog.d("doBindService done"); }
From source file:com.gmail.at.faint545.fragments.QueueFragment.java
private void setRecurringAlarm() { if (getRemote().getRefreshInterval() != -1) { updateTime = Calendar.getInstance(); updateTime.setTimeZone(TimeZone.getTimeZone("GMT")); updateTime.set(Calendar.MINUTE, 1); Intent downloader = new Intent(getActivity(), AlarmReciever.class); downloader.putExtra("url", getRemote().buildURL()); downloader.putExtra("api", getRemote().getApiKey()); downloader.putExtra("messenger", new Messenger(handler)); PendingIntent recurringDownload = PendingIntent.getBroadcast(getActivity(), 0, downloader, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarms = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); alarms.setInexactRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(), getRemote().getRefreshInterval(), recurringDownload); } else {/*from w ww.j a v a 2 s . c o m*/ downloadQueue(null); } }