List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.egoclean.arm.ui.ArmActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); outputController = new OutputController(this); setContentView(R.layout.main);//from w w w . j av a 2 s. com ArmView armView = (ArmView) findViewById(R.id.arm_view); armView.setAngleListener(outputController); mNotConnected = findViewById(R.id.lnl_not_connected); if (mAccessory != null) { showControls(); } else { hideControls(); } }
From source file:com.lonepulse.icklebot.activity.support.NetworkFragmentActivity.java
/** * <p>Registers a {@link BroadcastReceiver} to listen for changes in the data * connection state and invoke the appropriate callbacks. */// w w w . ja va2s .c o m @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (ProfileService.getInstance(getApplicationContext()).isActive(this, Profile.NETWORK)) { if (!PermissionUtils.isGranted(this, Manifest.permission.ACCESS_NETWORK_STATE)) { Log.e(getClass().getSimpleName(), "Failed to register a receiver for changes in network state. ", new IckleBotRuntimeException(new PermissionDeniedException( Manifest.permission.ACCESS_NETWORK_STATE, Profile.NETWORK))); } else { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(networkStateReceiver, intentFilter); } } }
From source file:com.lonepulse.icklebot.fragment.support.NetworkFragment.java
/** * <p>Registers a {@link BroadcastReceiver} to listen for changes in the data * connection state and invoke the appropriate callbacks. *///from www .j a v a2 s . co m @Override public void onResume() { super.onResume(); if (ProfileService.getInstance(getActivity().getApplicationContext()).isActive(this, Profile.NETWORK)) { if (!PermissionUtils.isGranted(this, Manifest.permission.ACCESS_NETWORK_STATE)) { Log.e(getClass().getSimpleName(), "Failed to register a receiver for changes in network state. ", new IckleBotRuntimeException(new PermissionDeniedException( Manifest.permission.ACCESS_NETWORK_STATE, Profile.NETWORK))); } else { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); getActivity().registerReceiver(networkStateReceiver, intentFilter); } } }
From source file:co.vanir.indecentxposure.IndecentXposure.java
void start(Context context) { //become a real boy! IntentFilter packageAddOrRemovedFilter = new IntentFilter(); packageAddOrRemovedFilter.addAction("android.intent.action.PACKAGE_ADDED"); packageAddOrRemovedFilter.addAction("android.intent.action.PACKAGE_REMOVED"); packageAddOrRemovedFilter.addDataScheme("package"); context.registerReceiver(this, packageAddOrRemovedFilter); //if we're here, and the user hasn't yet explicitly acknowledged the risk of their choice // GET ALL UP IN THEIR GRILL. boolean userDoesntWantTheirPhoneToWork = SerialOffender.hasXposedInstaller(context); if (!SerialOffender.getIgnoredState(context) && userDoesntWantTheirPhoneToWork) { //if the user hasn't acknowledged they're probably causing their own bugs by // having xposed installed, and the installer is present, then pop up a fresh // reminder IndecentXposure.notify(context, "XposedInstaller detected"); }//w ww .j av a2 s .c om }
From source file:com.liferay.alerts.activity.CommentsActivity.java
private void _registerBroadcastReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_ADD_COMMENT); filter.addAction(ACTION_UPDATE_COMMENTS_LIST); _receiver = new BroadcastReceiver() { @Override// w w w . ja v a 2s. c om public void onReceive(Context context, Intent intent) { String action = intent.getAction(); ListView listView = (ListView) findViewById(R.id.comments); if (ACTION_UPDATE_COMMENTS_LIST.equals(action)) { ArrayList<Alert> alerts = intent.getParcelableArrayListExtra(EXTRA_ALERTS); ArrayAdapter<Alert> adapter = new CommentListAdapter(getApplicationContext(), alerts); listView.setAdapter(adapter); } else if (ACTION_ADD_COMMENT.equals(action)) { Alert alert = intent.getParcelableExtra(EXTRA_ALERT); ArrayAdapter<Alert> adapter = (ArrayAdapter<Alert>) listView.getAdapter(); adapter.add(alert); } } }; _getBroadcastManager().registerReceiver(_receiver, filter); }
From source file:com.android.leanlauncher.LauncherAppState.java
private LauncherAppState() { if (sContext == null) { throw new IllegalStateException("LauncherAppState inited before app context set"); }//from w w w . java 2 s . c o m Log.v(Launcher.TAG, "LauncherAppState inited"); // set sIsScreenXLarge and mScreenDensity *before* creating icon cache mIsScreenLarge = isScreenLarge(sContext.getResources()); mScreenDensity = sContext.getResources().getDisplayMetrics().density; recreateWidgetPreviewDb(); mIconCache = new IconCache(sContext); mItemIdToViewId = new ArrayMap<>(); mModel = new LauncherModel(this, mIconCache); final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(sContext); launcherApps.addOnAppsChangedCallback(mModel); // Register intent receivers IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_LOCALE_CHANGED); filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); sContext.registerReceiver(mModel, filter); }
From source file:arun.com.chromer.webheads.ui.context.WebHeadContextActivity.java
private void registerEventsReceiver() { final IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_EVENT_WEBHEAD_DELETED); filter.addAction(ACTION_EVENT_WEBSITE_UPDATED); LocalBroadcastManager.getInstance(this).registerReceiver(webHeadsEventsReceiver, filter); }
From source file:com.codestation.henkakuserver.MainActivity.java
private void initBroadcastReceiverNetworkStateChanged() { final IntentFilter filters = new IntentFilter(); filters.addAction("android.net.wifi.WIFI_STATE_CHANGED"); filters.addAction("android.net.wifi.STATE_CHANGE"); filters.addAction("android.net.wifi.WIFI_AP_STATE_CHANGED"); broadcastReceiverNetworkState = new BroadcastReceiver() { @Override/* w w w. jav a2s .co m*/ public void onReceive(Context context, Intent intent) { setIpAccess(); } }; super.registerReceiver(broadcastReceiverNetworkState, filters); }
From source file:com.chao.facebookzc.internal.SessionTracker.java
private void addBroadcastReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction(Session.ACTION_ACTIVE_SESSION_SET); filter.addAction(Session.ACTION_ACTIVE_SESSION_UNSET); // Add a broadcast receiver to listen to when the active Session // is set or unset, and add/remove our callback as appropriate broadcastManager.registerReceiver(receiver, filter); }
From source file:com.dena.app.usage.watcher.MainActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mHandler = new Handler(); startSplash();/* w ww . java 2 s .c o m*/ mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); WatchReceiver watchReceiver = new WatchReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WatchService.WATCH_ACTION); registerReceiver(watchReceiver, intentFilter); watchReceiver.registerHandler(new Handler() { public void handleMessage(Message msg) { if (null == mSwitchCompat) { return; } Bundle bundle = msg.getData(); String message = bundle.getString(WatchService.WATCH_MESSAGE); if (message.equals(WatchService.WATCH_ACTION)) { mSwitchCompat.setChecked(true); } } }); }