当前位置: 首页>>代码示例>>Java>>正文


Java LocalBroadcastManager类代码示例

本文整理汇总了Java中android.support.v4.content.LocalBroadcastManager的典型用法代码示例。如果您正苦于以下问题:Java LocalBroadcastManager类的具体用法?Java LocalBroadcastManager怎么用?Java LocalBroadcastManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LocalBroadcastManager类属于android.support.v4.content包,在下文中一共展示了LocalBroadcastManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onNotificationPosted

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
    String pack = sbn.getPackageName();
    String ticker = sbn.getNotification().tickerText.toString();
    Bundle extras = sbn.getNotification().extras;
    String title = extras.getString("android.title");
    String text = extras.getCharSequence("android.text").toString();

    Log.i("Package",pack);
    Log.i("Ticker",ticker);
    Log.i("Title",title);
    Log.i("Text",text);

    Intent msgrcv = new Intent("Msg");
    msgrcv.putExtra("package", pack);
    msgrcv.putExtra("ticker", ticker);
    msgrcv.putExtra("title", title);
    msgrcv.putExtra("text", text);

    LocalBroadcastManager.getInstance(context).sendBroadcast(msgrcv);


}
 
开发者ID:ayc3ue,项目名称:NotificationsApp,代码行数:24,代码来源:MyNLS.java

示例2: onCreateView

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_station_lobby, container, false);

    IntentFilter filter = new IntentFilter();
    filter.addAction(StationActivity.ACTION_MAIN_SERVICE_BOUND);
    LocalBroadcastManager bm = LocalBroadcastManager.getInstance(getContext());
    bm.registerReceiver(mBroadcastReceiver, filter);

    lobbiesLayout = (LinearLayout) view.findViewById(R.id.lobbies_layout);

    update();

    return view;
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:18,代码来源:StationLobbyFragment.java

示例3: checksOnEventReceivedPushNotCalledWhenTelemetryDisabled

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Test
public void checksOnEventReceivedPushNotCalledWhenTelemetryDisabled() throws Exception {
  Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS);
  MapboxTelemetry.applicationContext = mockedContext;
  String aValidAccessToken = "validAccessToken";
  String aValidUserAgent = "MapboxTelemetryAndroid/";
  EventsQueue mockedEventsQueue = mock(EventsQueue.class);
  TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class);
  Callback mockedHttpCallback = mock(Callback.class);
  SchedulerFlusher mockedSchedulerFlusher = mock(SchedulerFlusher.class);
  Clock mockedClock = mock(Clock.class);
  LocalBroadcastManager mockedLocalBroadcastManager = mock(LocalBroadcastManager.class);
  boolean indifferentServiceBound = true;
  MapboxTelemetry theMapboxTelemetry = new MapboxTelemetry(mockedContext, aValidAccessToken, aValidUserAgent,
    mockedEventsQueue, mockedTelemetryClient, mockedHttpCallback, mockedSchedulerFlusher, mockedClock,
    mockedLocalBroadcastManager, indifferentServiceBound);
  Event mockedEvent = mock(Event.class);

  theMapboxTelemetry.onEventReceived(mockedEvent);

  verify(mockedEventsQueue, never()).push(eq(mockedEvent));
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:23,代码来源:MapboxTelemetryTest.java

示例4: registerReceiverAction

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
/**
 * @param action
 */
private final void registerReceiverAction(final String action) {
    IntentFilter filter = new IntentFilter(action);
    LocalBroadcastManager.getInstance(mContext).registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (action.equals(intent.getAction())) {
                PluginInfo info = intent.getParcelableExtra("obj");
                if (info != null) {
                    switch (action) {
                        case ACTION_NEW_PLUGIN:
                            // 非常驻进程上下文
                            newPluginFound(info, intent.getBooleanExtra(RePluginConstants.KEY_PERSIST_NEED_RESTART, false));
                            break;
                        case ACTION_UNINSTALL_PLUGIN:
                            pluginUninstalled(info);
                            break;
                    }
                }
            }
        }
    }, filter);
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:27,代码来源:PluginMgr.java

示例5: onDestroy

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Override
    public void onDestroy() {
        if (server != null) {
            try {
                LocalBroadcastManager.getInstance(this).unregisterReceiver(messageReceiver);
//                server.stop();
                server.shutdownNow();
                server = null;
                Intent statusIntent = new Intent(DeskDroidService.SERVER_STATUS_CHANGE);
                statusIntent.putExtra("running", false);
                LocalBroadcastManager.getInstance(this).sendBroadcast(statusIntent);
            } catch (Exception e) {
            }
        }
        super.onDestroy();
    }
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:17,代码来源:DeskDroidService.java

示例6: AndroidJSTPConnection

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
public AndroidJSTPConnection(String host, int port, boolean usesSSL, Context context) {
    mListeners = new CopyOnWriteArrayList<>();
    mTaggedCacheCalls = new ConcurrentHashMap<>();
    mConnectionState = STATE_NOT_CONNECTED;

    mNeedsRestoration = true;
    mContext = context;

    TCPTransport transport = new TCPTransport(host, port, usesSSL);
    mConnection = new Connection(transport, this);
    mConnection.addSocketListener(this);

    mBroadcastManager = LocalBroadcastManager.getInstance(mContext);

    initNetworkReceiver();
}
 
开发者ID:metarhia,项目名称:metacom-android,代码行数:17,代码来源:AndroidJSTPConnection.java

示例7: onMessageReceived

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals("/heartRate")) {
        final String message = new String(messageEvent.getData());
        Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath());
        Log.v("packtchat", "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("heart", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
 
开发者ID:PacktPublishing,项目名称:Android-Wear-Projects,代码行数:18,代码来源:HeartListener.java

示例8: onCreate

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    s = new Setting();
    Language = s.getLang();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    Language = preferences.getString("l",Language);
    setLanguage(Language);
    setContentView(R.layout.activity_main);
    BottomNavigationView navigation =  findViewById(R.id.navigation);
    navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    fm=getSupportFragmentManager();
    fm.beginTransaction().add(R.id.content,new BlankFragment()).commit();
    Intent i = new Intent(this,SocketService.class);
    bindService(i,myConnection,Context.BIND_AUTO_CREATE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Log.e("Brodcast","Broadcast intent onCreate invoked");
    if(savedInstanceState == null){
    if(!registred){
        LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
                new IntentFilter("my-event"));
        Log.e("Registre","Broadcast intent  register");
        registred = true;
    }}

}
 
开发者ID:RRDL,项目名称:CRT,代码行数:27,代码来源:MainActivity.java

示例9: 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);
}
 
开发者ID:pkargupta,项目名称:gyrodrone,代码行数:26,代码来源:DroneDiscoverer.java

示例10: onNotifactionShowedResult

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Override
public void onNotifactionShowedResult(Context context, XGPushShowedResult xgPushShowedResult) {
    LogUtils.d(TAG, xgPushShowedResult.toString());
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss", Locale.CHINA);

    Notice notice = new Notice();
    notice.setTitle(xgPushShowedResult.getTitle());
    notice.setContent(xgPushShowedResult.getContent());
    notice.setTime(simpleDateFormat.format(new Date()));
    notice.setUserId(getLoginUser());
    NoticeDao noticeDao = getDaoSession().getNoticeDao();
    noticeDao.insert(notice);

    //发送广播通知更新
    Intent intent = new Intent(Constants.mainBroadcast);
    Bundle bundle = new Bundle();
    bundle.putInt("type", Constants.BROADCAST_TYPE_NOTICE);
    intent.putExtras(bundle);
    LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:21,代码来源:XinGeReceiver.java

示例11: checksUserAgentEvents

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Test
public void checksUserAgentEvents() throws Exception {
  Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS);
  MapboxTelemetry.applicationContext = mockedContext;
  String aValidAccessToken = "validAccessToken";
  String theEventsAndroidAgent = "MapboxEventsAndroid/";
  EventsQueue mockedEventsQueue = mock(EventsQueue.class);
  TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class);
  Callback mockedHttpCallback = mock(Callback.class);
  SchedulerFlusher mockedSchedulerFlusher = mock(SchedulerFlusher.class);
  Clock mockedClock = mock(Clock.class);
  LocalBroadcastManager mockedLocalBroadcastManager = mock(LocalBroadcastManager.class);
  boolean indifferentServiceBound = true;
  MapboxTelemetry theMapboxTelemetry = new MapboxTelemetry(mockedContext, aValidAccessToken, theEventsAndroidAgent,
    mockedEventsQueue, mockedTelemetryClient, mockedHttpCallback, mockedSchedulerFlusher, mockedClock,
    mockedLocalBroadcastManager, indifferentServiceBound);
  theMapboxTelemetry.enable();

  boolean validRequiredParameters = theMapboxTelemetry.checkRequiredParameters(aValidAccessToken,
    theEventsAndroidAgent);

  assertTrue(validRequiredParameters);
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:24,代码来源:MapboxTelemetryTest.java

示例12: run

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Override
public void run() {
    try {
        sleep(500);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    LocalBroadcastManager _manager = LocalBroadcastManager.getInstance(Global.get_applicationContext());
    SDFile _file;
    for (int _temp_i = 0; _temp_i < _files.size(); _temp_i++) {
        _file = _files.valueAt(_temp_i);
        _file.updateRubbish();
        Intent _update = new Intent(ACTION_UPDATE);
        _update.putExtra("index", _files.keyAt(_temp_i));
        _manager.sendBroadcast(_update);
    }
    Intent _finish = new Intent(ACTION_FINISH);
    _manager.sendBroadcast(_finish);
}
 
开发者ID:bonepeople,项目名称:SDCardCleaner,代码行数:20,代码来源:UpdateRubbishThread.java

示例13: checksInvalidUserAgent

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Test
public void checksInvalidUserAgent() throws Exception {
  Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS);
  MapboxTelemetry.applicationContext = mockedContext;
  String aValidAccessToken = "validAccessToken";
  String aInvalidUserAgent = "invalidUserAgent";
  EventsQueue mockedEventsQueue = mock(EventsQueue.class);
  TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class);
  Callback mockedHttpCallback = mock(Callback.class);
  SchedulerFlusher mockedSchedulerFlusher = mock(SchedulerFlusher.class);
  Clock mockedClock = mock(Clock.class);
  LocalBroadcastManager mockedLocalBroadcastManager = mock(LocalBroadcastManager.class);
  boolean indifferentServiceBound = true;
  MapboxTelemetry theMapboxTelemetry = new MapboxTelemetry(mockedContext, aValidAccessToken, aInvalidUserAgent,
    mockedEventsQueue, mockedTelemetryClient, mockedHttpCallback, mockedSchedulerFlusher, mockedClock,
    mockedLocalBroadcastManager, indifferentServiceBound);
  theMapboxTelemetry.enable();

  boolean validRequiredParameters = theMapboxTelemetry.checkRequiredParameters(aValidAccessToken, aInvalidUserAgent);

  assertFalse(validRequiredParameters);
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:23,代码来源:MapboxTelemetryTest.java

示例14: getInstance

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
static AccessTokenManager getInstance() {
    if (instance == null) {
        synchronized (AccessTokenManager.class) {
            if (instance == null) {
                Context applicationContext = FacebookSdk.getApplicationContext();
                LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(
                        applicationContext);
                AccessTokenCache accessTokenCache = new AccessTokenCache();

                instance = new AccessTokenManager(localBroadcastManager, accessTokenCache);
            }
        }
    }

    return instance;
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:17,代码来源:AccessTokenManager.java

示例15: onCreate

import android.support.v4.content.LocalBroadcastManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_list_with_header);

	// Get the list component from the layout of the activity
	final WearableListView listView = (WearableListView) findViewById(R.id.devices_list);
	listView.setAdapter(mDeviceAdapter = new DevicesAdapter(listView));
	listView.setClickListener(mOnRowClickListener);
	listView.addOnScrollListener(mOnScrollListener);

	// The header will be moved as the list is scrolled
	mHeader = findViewById(R.id.header);

	// Register a broadcast receiver that will listen for events from the service.
	LocalBroadcastManager.getInstance(this).registerReceiver(mServiceBroadcastReceiver, BleProfileService.makeIntentFilter());
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:18,代码来源:ScannerActivity.java


注:本文中的android.support.v4.content.LocalBroadcastManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。