本文整理匯總了Java中android.support.v4.content.LocalBroadcastManager.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalBroadcastManager.getInstance方法的具體用法?Java LocalBroadcastManager.getInstance怎麽用?Java LocalBroadcastManager.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.content.LocalBroadcastManager
的用法示例。
在下文中一共展示了LocalBroadcastManager.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
getActivity().setTitle(getString(R.string.frag_notif_title));
if (mListener != null) {
mListener.checkNavigationDrawerItem(R.id.nav_notif);
}
FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
fab.hide();
SwipeRefreshLayout srl = (SwipeRefreshLayout) getActivity().findViewById(R.id.swipe_container);
srl.setEnabled(false);
IntentFilter filter = new IntentFilter();
filter.addAction(MainActivity.ACTION_MAIN_SERVICE_BOUND);
filter.addAction(MainService.ACTION_UPDATE_TOPOLOGY_FINISHED);
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(view.getContext());
bm.registerReceiver(mBroadcastReceiver, filter);
return view;
}
示例2: onCreate
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_music_player);
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
localBroadcastManager = LocalBroadcastManager.getInstance(this);
musicApplication = (GlobalVariable) getApplication();
music = (MusicList) musicApplication.getTheList().get(musicApplication.getMusicPosition());
//初始化組件
getView();
initView();
setMusicPlayerService();
mMusicPlayerService.setMusicPlayerActivity(this);
mMusicPlayerService.transPleyerToMain();
circleSeekBar.setmActivity(this);
//填充歌詞
httpConn = new HttpConn(music.getSinger(), music.getMusicName(), handler);
//廣播發送器
}
示例3: intiData
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
private void intiData() {
// 創建一個會話的fragment
easeChatFragment = new EaseChatFragment();
mHxid = getIntent().getStringExtra(EaseConstant.EXTRA_USER_ID);
// 獲取聊天類型
mChatType = getIntent().getExtras().getInt(EaseConstant.EXTRA_CHAT_TYPE);
easeChatFragment.setArguments(getIntent().getExtras());
// 替換fragment
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fl_chat, easeChatFragment).commit();
// 獲取發送廣播的管理者
mLocalBroadcastManager = LocalBroadcastManager.getInstance(ChatActivity.this);
}
示例4: cleanup
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
/**
* Cleanup the object
* Should be called when the object is not used anymore
*/
public void cleanup() {
stopDiscovering();
//close discovery service
Log.d(TAG, "closeServices ...");
if (mArdiscoveryService != null) {
new Thread(new Runnable() {
@Override
public void run() {
mArdiscoveryService.stop();
mCtx.unbindService(mArdiscoveryServiceConnection);
mArdiscoveryService = null;
}
}).start();
}
// unregister receivers
LocalBroadcastManager localBroadcastMgr = LocalBroadcastManager.getInstance(mCtx);
localBroadcastMgr.unregisterReceiver(mArdiscoveryServicesDevicesListUpdatedReceiver);
}
示例5: onCreateView
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home_stats, container, false);
Context context = view.getContext();
lineStatsLayout = (TableLayout) view.findViewById(R.id.line_stats_layout);
progressBar = (ProgressBar) view.findViewById(R.id.loading_indicator);
lastDisturbanceView = (HtmlTextView) view.findViewById(R.id.last_disturbance_view);
progressBar.setVisibility(View.VISIBLE);
updateInformationView = (TextView) view.findViewById(R.id.update_information);
IntentFilter filter = new IntentFilter();
filter.addAction(MainActivity.ACTION_MAIN_SERVICE_BOUND);
filter.addAction(MainService.ACTION_UPDATE_TOPOLOGY_FINISHED);
filter.addAction(StatsCache.ACTION_STATS_UPDATE_STARTED);
filter.addAction(StatsCache.ACTION_STATS_UPDATE_SUCCESS);
filter.addAction(StatsCache.ACTION_STATS_UPDATE_FAILED);
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(context);
bm.registerReceiver(mBroadcastReceiver, filter);
redraw(context);
return view;
}
示例6: bindModel
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
public void bindModel(@NonNull App app) {
currentApp = app;
ImageLoader.getInstance().displayImage(app.iconUrl, icon, displayImageOptions);
// Figures out the current install/update/download/etc status for the app we are viewing.
// Then, asks the view to update itself to reflect this status.
Iterator<AppUpdateStatus> statuses =
AppUpdateStatusManager.getInstance(activity).getByPackageName(app.packageName).iterator();
if (statuses.hasNext()) {
AppUpdateStatus status = statuses.next();
updateAppStatus(app, status);
} else {
updateAppStatus(app, null);
}
final LocalBroadcastManager broadcastManager =
LocalBroadcastManager.getInstance(activity.getApplicationContext());
broadcastManager.unregisterReceiver(onStatusChanged);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED);
intentFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
intentFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED);
broadcastManager.registerReceiver(onStatusChanged, intentFilter);
}
示例7: onResumeFragments
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
protected void onResumeFragments() {
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG);
super.onResumeFragments();
/* Showing dialog in onResume() fails with:
* Can not perform this action after onSaveInstanceState
*/
if (mImportChosenBook != null) {
importChosenBook(mImportChosenBook);
mImportChosenBook = null;
}
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(this);
bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_OPEN_NOTE));
bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_OPEN_BOOK));
}
示例8: initBroadcastReceiver
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
private void initBroadcastReceiver() {
// 注冊廣播接收者
mBroadcastManager = LocalBroadcastManager.getInstance(this);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(AppDelegate.ACTION_T_REFRESH_APPLY_PAYMENT_LIST);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
reLoad();
}
};
mBroadcastManager.registerReceiver(mReceiver, intentFilter);
}
示例9: bindReceiver
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
private void bindReceiver(final T view) {
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
handleIntent(view, intent);
}
};
manager = LocalBroadcastManager.getInstance(context);
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_VIEW);
filter.addCategory(Intent.CATEGORY_DEFAULT);
final Uri[] uris = new Uri[kolibriUris().length];
for (int i = 0; i < uris.length; ++i) {
uris[i] = Uri.parse(kolibriUris()[i]);
final Uri uri = uris[i];
filter.addDataScheme(uri.getScheme());
filter.addDataAuthority(uri.getHost(), null);
}
manager.registerReceiver(receiver, filter);
}
示例10: register
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
private void register() {
musicService = RairApp.getApp().getService();
receiver = new OptionReceiver();
IntentFilter intentFilter = new IntentFilter(Constants.ACTION_SEND);
broadcastManager = LocalBroadcastManager.getInstance(getContext());
broadcastManager.registerReceiver(receiver, intentFilter);
}
示例11: MusicFromSingerAndAlbum
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
public MusicFromSingerAndAlbum(Context context,int num,String name){
this.listContainer = LayoutInflater.from(context);
this.mcontext = context;
this.global = (GlobalVariable) context.getApplicationContext();
if (name.equals("singer")){
this.musiclist = global.getSingerListList().get(num).getMusicListBelongSinger();
}
if (name.equals("album")){
this.musiclist = global.getAlbumListList().get(num).getMusicListBelongAlbum();
}
this.localBroadcastManager = LocalBroadcastManager.getInstance(context);
}
示例12: associateWithLikeActionController
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
private void associateWithLikeActionController(LikeActionController likeActionController) {
this.likeActionController = likeActionController;
this.broadcastReceiver = new LikeControllerBroadcastReceiver();
LocalBroadcastManager localBroadcastManager =
LocalBroadcastManager.getInstance(getContext());
// add the broadcast receiver
IntentFilter filter = new IntentFilter();
filter.addAction(LikeActionController.ACTION_LIKE_ACTION_CONTROLLER_UPDATED);
filter.addAction(LikeActionController.ACTION_LIKE_ACTION_CONTROLLER_DID_ERROR);
filter.addAction(LikeActionController.ACTION_LIKE_ACTION_CONTROLLER_DID_RESET);
localBroadcastManager.registerReceiver(broadcastReceiver, filter);
}
示例13: emitEventContext
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
/**
* Post an event to all event subscriber for the given name
* Example: MSREventBridgeModule.emitEventContext(getApplicationContext(), "eventName", data);
*/
static public void emitEventContext(Context context, final String name, @Nullable WritableMap info) {
Bundle bundle = new Bundle();
bundle.putString(EventBridgeModuleEventNameKey, name);
if (info != null) {
bundle.putBundle(EventBridgeModuleEventInfoKey, Arguments.toBundle(info));
}
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
Intent customEvent= new Intent(EventBridgeModuleIntentEventName);
customEvent.putExtra(EventBridgeModuleIntentEventDataKey, bundle);
localBroadcastManager.sendBroadcast(customEvent);
}
示例14: LoriAuthController
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Inject
public LoriAuthController(LoriApp app, TokenStore tokenStore, final LoriApiService service, AppExecutors executors) {
this.service = service;
this.executors = executors;
this.broadcastManager = LocalBroadcastManager.getInstance(app);
this.service.setListener(this);
this.tokenStore = tokenStore;
executors.background().execute(new Runnable() {
@Override
public void run() {
String token = tokenStore.loadToken();
service.setToken(token);
}
});
}
示例15: buildBroadcast
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
private void buildBroadcast(){
if (!isSendBroadcast){
return;
}
localBroadcastManager = LocalBroadcastManager.getInstance(this);
localIntent = new Intent(ACTION);
}