List of usage examples for android.support.v4.content LocalBroadcastManager getInstance
public static LocalBroadcastManager getInstance(Context context)
From source file:com.afrolkin.samplepushclient.GCMIntentService.java
@Override protected void onUnregistered(Context arg0, String arg1) { Log.i(TAG, "Device unregistered: " + arg1); // Send local broadcast to notify main activity of successful unregistration Intent intent = new Intent(getString(R.string.register_status_action)); intent.putExtra(getString(R.string.register_status_extra), false); intent.putExtra(getString(R.string.error_extra), false); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); }
From source file:com.acrr.acdisplay.services.BathService.java
public static void stopService(Context context, Class<? extends ChildService> clazz) { synchronized (monitor) { if (sRunning) { Intent intent = new Intent(ACTION_REMOVE_SERVICE); intent.putExtra(EXTRA_SERVICE_CLASS, clazz); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); } else {/* w ww . j av a2 s . c o m*/ sServiceMap.remove(clazz); } } }
From source file:ca.zadrox.dota2esportticker.ui.TeamOverviewFragment.java
@Override public void onPause() { super.onPause(); LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mBroadcastReceiver); LogUtils.LOGD(TAG, "onPause"); }
From source file:am.util.mvp.AMActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); int layout = getContentViewLayout(); if (layout != 0) { setContentView(layout);//from www . j a v a 2s . c o m } initializeActivity(savedInstanceState); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); final IntentFilter filter = new IntentFilter(); onAddLocalAction(filter); mLocalBroadcastManager.registerReceiver(mLocalBroadcastReceiver, filter); onRegisteredLocalBroadcastReceiver(); mLoading = getLoadingDialog(); final AMPresenter presenter = getPresenter(); if (presenter != null) { presenter.onCreated(savedInstanceState); } }
From source file:ca.hoogit.garagepi.Controls.DoorManager.java
public void stop() { LocalBroadcastManager.getInstance(mContext).unregisterReceiver(this); mIsRegistered = false; }
From source file:am.util.mvp.AMFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); initializeFragment(getActivity(), savedInstanceState); if (isLocalBroadcastEnable()) { mLocalBroadcastManager = LocalBroadcastManager.getInstance(getActivity()); IntentFilter filter = new IntentFilter(); onAddLocalAction(filter);/*from w w w . ja va 2 s .c om*/ mLocalBroadcastManager.registerReceiver(mLocalBroadcastReceiver, filter); onRegisteredLocalBroadcastReceiver(); } }
From source file:com.achep.acdisplay.services.BathService.java
public static void stopService(Context context, Class<? extends ChildService> clazz) { synchronized (monitor) { if (sCreated) { // Send broadcast intent to notify BathService // to stop this child. Intent intent = new Intent(ACTION_REMOVE_SERVICE); intent.putExtra(EXTRA_SERVICE_CLASS, clazz); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); } else {//from w w w . ja v a2 s.c om // Service is not created, so I can handle hash map manually. sServiceMap.remove(clazz); } } }
From source file:ca.hoogit.hooold.Scheduling.Sms.java
public void send(Context context) { int count = 1; SmsManager manager = SmsManager.getDefault(); for (String recipient : this.recipients) { if (manager == null) { Intent error = generateIntent(Consts.INTENT_SMS_SENT, recipient, count); LocalBroadcastManager.getInstance(context).sendBroadcast(error); } else if (messageBody.length() <= Consts.MAX_SMS_LENGTH) { Log.i(TAG, "Message will be sent as single"); single(context, manager, recipient, count); } else {/*from w ww . j av a2s. c o m*/ Log.i(TAG, "Message will be sent in multiple parts"); multiple(context, manager, recipient, count); } Log.d(TAG, "Sending message to: " + recipient); count++; } if (manager != null) { Log.i(TAG, "Message sent to " + this.recipients.size() + " recipients"); } else { Toast.makeText(context, R.string.error_sms_manager_default, Toast.LENGTH_LONG).show(); Log.e(TAG, "send: Could not get default sms manager"); } }
From source file:am.util.mvp.AMSupportFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); initializeFragment(getActivity(), savedInstanceState); if (isLocalBroadcastEnable() && getActivity() != null) { mLocalBroadcastManager = LocalBroadcastManager.getInstance(getActivity()); IntentFilter filter = new IntentFilter(); onAddLocalAction(filter);/*w ww .j a v a2 s . c o m*/ mLocalBroadcastManager.registerReceiver(mLocalBroadcastReceiver, filter); onRegisteredLocalBroadcastReceiver(); } }
From source file:com.android.tv.settings.device.storage.UnmountActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mUnmountVolumeId = getIntent().getStringExtra(VolumeInfo.EXTRA_VOLUME_ID); mUnmountVolumeDesc = getIntent().getStringExtra(EXTRA_VOLUME_DESC); LocalBroadcastManager.getInstance(this).registerReceiver(mUnmountReceiver, new IntentFilter(SettingsStorageService.ACTION_UNMOUNT)); if (savedInstanceState == null) { final StorageManager storageManager = getSystemService(StorageManager.class); final VolumeInfo volumeInfo = storageManager.findVolumeById(mUnmountVolumeId); if (volumeInfo == null) { // Unmounted already, just bail finish();//from w w w .ja v a 2 s . com return; } if (volumeInfo.getType() == VolumeInfo.TYPE_PRIVATE) { final Fragment fragment = UnmountPrivateStepFragment.newInstance(mUnmountVolumeId); getFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit(); } else { // Jump straight to unmounting onRequestUnmount(); } } }