List of usage examples for android.os Messenger Messenger
public Messenger(IBinder target)
From source file:org.lunci.dumbthing.fragment.ServiceFragmentBase.java
@Override public void onServiceConnected(ComponentName name, IBinder service) { mServiceMessenger = new Messenger(service); mBound = true; }
From source file:org.lunci.lunci_waveform_fragments.Fragment_ServiceManagerBase.java
@Override public void onServiceConnected(ComponentName name, IBinder service) { mServiceFunction = (IDataService) service; mServiceMessenger = new Messenger(mServiceFunction.getMessengerBinder()); mBound = true;/*from w w w .j a v a 2 s . com*/ if (BuildConfig.DEBUG) { Log.i(TAG, "onServiceConnected, id=" + mServiceKey); } }
From source file:eu.esu.mobilecontrol2.sdk.MessageServiceFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mReceiver = new Messenger(new IncomingMessageHandler(new WeakReference<>(this))); // Ignore input services on 3rd party devices to prevent crashes. if (MobileControl2.isMobileControl2() && InputServices.isInstalled(getActivity())) { getActivity().bindService(getServiceIntent(), mConnection, Context.BIND_AUTO_CREATE); }// w ww . j av a 2 s . c om }
From source file:org.lunci.lunci_waveform_example.ActivityServiceManagerBase.java
@Override public void onServiceConnected(ComponentName name, IBinder service) { // mMessenger = new Messenger(getHandler()); mBound = true;/*from w w w. j a v a2s.c om*/ if (BuildConfig.DEBUG) { Log.i(TAG, "onServiceConnected, id=" + mServiceKey); } mServiceFunction = (IDataService) service; mServiceMessenger = new Messenger(mServiceFunction.getMessengerBinder()); }
From source file:org.hedgewars.hedgeroid.Downloader.DownloadFragment.java
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); messageHandler = new Handler(messageCallback); messenger = new Messenger(messageHandler); Intent i = new Intent(getActivity().getApplicationContext(), DownloadService.class); getActivity().startService(i);/*from w ww . j a v a 2 s. c o m*/ getActivity().bindService(new Intent(getActivity().getApplicationContext(), DownloadService.class), connection, Context.BIND_AUTO_CREATE); }
From source file:org.gearvrf.weartouchpad.WearInputService.java
@Override public void onCreate() { super.onCreate(); apiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build(); apiClient.connect();//from w w w. j a va 2 s . com nodes = new HashSet<Node>(); receiveMessenger = new Messenger(new IncomingMsgHandler()); broadcastManager = LocalBroadcastManager.getInstance(this); localBinder = new LocalBinder(); connectedToWatch = false; int touchScreenDeviceId = 0; InputManager im = (InputManager) getSystemService(Context.INPUT_SERVICE); for (int inputDevId : im.getInputDeviceIds()) { InputDevice inputDevice = im.getInputDevice(inputDevId); if ((inputDevice.getSources() & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) { touchScreenDeviceId = inputDevId; break; } } motionEventGenerator = new MotionEventGenerator(touchScreenDeviceId); }
From source file:org.opensilk.music.ui2.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Bind Apollo's service mMusicService.bind();//from w w w.j ava 2 s. c o m // Control the media volume setVolumeControlStream(AudioManager.STREAM_MUSIC); isCastingEnabled = checkCastingEnabled(); if (isCastingEnabled) { // Bind cast service mCastServiceToken = RemoteCastServiceManager.bindToService(this, new Messenger(new CastManagerCallbackHandler(this)), null); // Initialize the media router mMediaRouter = MediaRouter.getInstance(this); mMediaRouteSelector = new MediaRouteSelector.Builder() .addControlCategory(CastMediaControlIntent.categoryForCast(getString(R.string.cast_id))) //.addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO) .build(); } }
From source file:name.marinchenko.lorryvision.activities.main.MainActivity.java
/** * Activity lifecycle: activity launched * @param savedInstanceState saved state of the activity *///from w w w .ja v a 2 s . c om @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.messenger = new Messenger(new MainIncomingHandler(this)); this.netlistAdapter = Initializer.Main.initNetlist(this); Initializer.Main.init(this); }
From source file:id.nci.stm_9.DeleteFileDialogFragment.java
/** * Creates dialog//from w w w. j a v a 2 s . c om */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final FragmentActivity activity = getActivity(); final String deleteFile = getArguments().getString(ARG_DELETE_FILE); AlertDialog.Builder alert = new AlertDialog.Builder(activity); alert.setIcon(android.R.drawable.ic_dialog_alert); alert.setTitle(R.string.warning); alert.setMessage(this.getString(R.string.file_delete_confirmation, deleteFile)); alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dismiss(); // Send all information needed to service to edit key in other thread Intent intent = new Intent(activity, KeychainIntentService.class); // fill values for this action Bundle data = new Bundle(); intent.setAction(KeychainIntentService.ACTION_DELETE_FILE_SECURELY); data.putString(KeychainIntentService.DELETE_FILE, deleteFile); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); ProgressDialogFragment deletingDialog = ProgressDialogFragment .newInstance(R.string.progress_deleting_securely, ProgressDialog.STYLE_HORIZONTAL); // Message is received after deleting is done in ApgService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity, deletingDialog) { public void handleMessage(Message message) { // handle messages by standard ApgHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { Toast.makeText(activity, R.string.file_delete_successful, Toast.LENGTH_SHORT).show(); } }; }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(saveHandler); intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); // show progress dialog deletingDialog.show(activity.getSupportFragmentManager(), "deletingDialog"); // start service with intent activity.startService(intent); } }); alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismiss(); } }); alert.setCancelable(true); return alert.create(); }
From source file:org.peercast.core.PeerCastServiceController.java
/** * PeerCastService???/*w ww . ja va 2s .c o m*/ * *<ul> * <li> * MSG_GET_APPLICATION_PROPERTIES = 0x00;<br> * ????<br> * : getInt("port") ??=0<br><br> * <li> * MSG_GET_CHANNELS = 0x01;<br> * ??????<br> * : nativeGetChannel()?<br> * : Channel.java <br><br> * <li> * MSG_GET_STATS = 0x02;<br> * ?????<br> * : nativeGetStats()?<br> * : Stats.java <br><br> * * @param what MSG_ ?? * @param listener ??Bundle???? */ public void sendCommand(int what, final OnServiceResultListener listener) { if (serverMessenger == null) new IllegalStateException("service not connected."); Message msg = Message.obtain(null, what); msg.replyTo = new Messenger(new Handler(new Handler.Callback() { //Handler??? @Override public boolean handleMessage(Message msg) { listener.onServiceResult(msg.getData()); return true; } })); try { serverMessenger.send(msg); } catch (RemoteException e) { Log.e(TAG, "what=" + what, e); } }