List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:fr.bmartel.android.fadecandy.service.FadecandyService.java
/** * Initialize broadcast receiver to receive USB ATTACHED/DETACHED events. *//*from ww w. ja va2s . c om*/ private void initBroadcastReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_USB_PERMISSION); filter.addAction(UsbEventReceiverActivity.ACTION_USB_DEVICE_ATTACHED); filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); filter.addAction(FadecandyService.ACTION_EXIT); registerReceiver(receiver, filter); }
From source file:com.dabay6.android.apps.carlog.ui.HomeActivity.java
/** * {@inheritDoc}/*from w ww. j a v a 2 s . co m*/ */ @Override protected void onResume() { final IntentFilter filter = new IntentFilter(); final SharedPreferencesHelper helper = new SharedPreferencesHelper(this); super.onResume(); isInitialized = helper.booleanValue(SharedPreferenceKeys.PREF_INITIALIZED, false); filter.addAction(Intents.INTENT_INIT_FINISHED); this.registerReceiver(this.initReceiver, filter); if (!isInitialized) { startInitializationService(); } else if (!isFinishing()) { final int result; result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); if (result != ConnectionResult.SUCCESS) { GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_REQUEST); } if (!ChangeLogDialogUtils.hasShownChangeLog(this)) { ChangeLogDialogUtils.displayChangeLogDialogFragment(this); } supportInvalidateOptionsMenu(); startLoader(); } }
From source file:com.mappn.gfan.ui.HomeTabActivity.java
private void registerReceivers() { IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mNetworkReceiver, filter); IntentFilter intentClickFilter = new IntentFilter(Constants.BROADCAST_CLICK_INTENT); registerReceiver(mIntentClickReceiver, intentClickFilter); IntentFilter appFilter = new IntentFilter(); appFilter.addAction(Intent.ACTION_PACKAGE_ADDED); appFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); appFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); appFilter.addDataScheme("package"); registerReceiver(mInstallReceiver, appFilter); IntentFilter updatefilter = new IntentFilter(); updatefilter.addAction(Constants.BROADCAST_FORCE_EXIT); updatefilter.addAction(Constants.BROADCAST_REMIND_LATTER); updatefilter.addAction(Constants.BROADCAST_DOWNLOAD_OPT); updatefilter.addAction(Constants.BROADCAST_DOWNLOAD); registerReceiver(mUpdateReceiver, updatefilter); }
From source file:com.android.music.AlbumBrowserActivity.java
/** Called when the activity is first created. */ @Override// w w w. j a v a2 s .c o m public void onCreate(Bundle icicle) { if (icicle != null) { mCurrentAlbumId = icicle.getString("selectedalbum"); mArtistId = icicle.getString("artist"); } else { mArtistId = getIntent().getStringExtra("artist"); } super.onCreate(icicle); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_NO_TITLE); setVolumeControlStream(AudioManager.STREAM_MUSIC); mToken = MusicUtils.bindToService(this, this); IntentFilter f = new IntentFilter(); f.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED); f.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED); f.addAction(Intent.ACTION_MEDIA_UNMOUNTED); f.addDataScheme("file"); registerReceiver(mScanListener, f); setContentView(R.layout.media_picker_activity); MusicUtils.updateButtonBar(this, R.id.albumtab); ListView lv = getListView(); lv.setOnCreateContextMenuListener(this); lv.setTextFilterEnabled(true); mAdapter = (AlbumListAdapter) getLastNonConfigurationInstance(); if (mAdapter == null) { //Log.i("@@@", "starting query"); mAdapter = new AlbumListAdapter(getApplication(), this, R.layout.track_list_item, mAlbumCursor, new String[] {}, new int[] {}); setListAdapter(mAdapter); setTitle(R.string.working_albums); getAlbumCursor(mAdapter.getQueryHandler(), null); } else { mAdapter.setActivity(this); setListAdapter(mAdapter); mAlbumCursor = mAdapter.getCursor(); if (mAlbumCursor != null) { init(mAlbumCursor); } else { getAlbumCursor(mAdapter.getQueryHandler(), null); } } badSymptoms = new BadSymptoms(this); }
From source file:com.hx.hxchat.activity.ChatHistoryFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); context = getActivity();//from ww w .ja va 2s. c o m gson = new Gson(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("ishxlogined"); getActivity().registerReceiver(myReceiver, intentFilter); inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); errorItem = (RelativeLayout) getView().findViewById(R.id.rl_error_item); errorText = (TextView) errorItem.findViewById(R.id.tv_connect_errormsg); // contact list progressDialog = CommonUtils.getUserDefinedDialog(context, "?...", false, true); listView = (ListView) getView().findViewById(R.id.list); // ?? initData(); }
From source file:cn.moon.superwechat.ui.MainActivity.java
private void registerBroadcastReceiver() { broadcastManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED); intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED); intentFilter.addAction(RPConstant.REFRESH_GROUP_RED_PACKET_ACTION); broadcastReceiver = new BroadcastReceiver() { @Override/*from www. j av a 2 s . co m*/ public void onReceive(Context context, Intent intent) { updateUnreadLabel(); updateUnreadAddressLable(); if (currentTabIndex == 0) { // refresh conversation list if (conversationListFragment != null) { conversationListFragment.refresh(); } } else if (currentTabIndex == 1) { if (contactListFragment != null) { contactListFragment.refresh(); } } String action = intent.getAction(); if (action.equals(Constant.ACTION_GROUP_CHANAGED)) { if (EaseCommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) { GroupsActivity.instance.onResume(); } } //red packet code : ??? if (action.equals(RPConstant.REFRESH_GROUP_RED_PACKET_ACTION)) { if (conversationListFragment != null) { conversationListFragment.refresh(); } } //end of red packet code } }; broadcastManager.registerReceiver(broadcastReceiver, intentFilter); }
From source file:com.aegiswallet.services.PeerBlockchainService.java
@Override public void onCreate() { super.onCreate(); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); application = (PayBitsApplication) getApplication(); prefs = PreferenceManager.getDefaultSharedPreferences(this); final Wallet wallet = application.getWallet(); blockChainFile = new File(getDir("blockstore", Context.MODE_PRIVATE), Constants.BLOCKCHAIN_FILENAME); final boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { wallet.clearTransactions(0);//from w w w.jav a2s.com wallet.setLastBlockSeenHeight(-1); wallet.setLastBlockSeenHash(null); } try { blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); blockStore.getChainHead(); // detect corruptions as early as possible long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); if (earliestKeyCreationTime == 0) earliestKeyCreationTime = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7); if (!blockChainFileExists && earliestKeyCreationTime > 0) { Log.d(TAG, "creating blockchain from checkpoint. attmpting to at least..."); try { final InputStream checkpointsInputStream = getAssets().open(Constants.CHECKPOINTS_FILENAME); CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsInputStream, blockStore, earliestKeyCreationTime); } catch (final IOException x) { Log.e(TAG, "problem reading checkpoint file..." + x.getMessage()); } } } catch (final BlockStoreException x) { blockChainFile.delete(); final String msg = "blockstore cannot be created"; throw new Error(msg, x); } try { blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0); final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); maybeRotateKeys(); tagPrefs = application.getSharedPreferences(getString(R.string.tag_pref_filename), Context.MODE_PRIVATE); }
From source file:com.ksksue.app.ftdi_uart.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //initialize GoogleApiClient instance for location mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).addApi(AppIndex.API).build(); tvRead = (TextView) findViewById(R.id.tvRead); tvRead.setMovementMethod(new ScrollingMovementMethod()); logRead = (TextView) findViewById(R.id.logRead); logRead.setMovementMethod(new ScrollingMovementMethod()); etWrite = (EditText) findViewById(R.id.etWrite); btWrite = (Button) findViewById(R.id.btWrite); debuger = (Button) findViewById(R.id.debug); joinBtn = (Button) findViewById(R.id.joinBtn); List<String> list = new ArrayList<String>(); list.add("Everyone"); spinnerDataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list); makeSpinner(spinnerDataAdapter);//w ww .j a v a2s . c o m updateView(false); try { ftD2xx = D2xxManager.getInstance(this); } catch (D2xxManager.D2xxException ex) { Log.e(TAG, ex.toString()); } IntentFilter filter = new IntentFilter(); filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); registerReceiver(mUsbReceiver, filter); }
From source file:at.vcity.androidimsocket.services.IMService.java
@Override public void onCreate() { mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); localstoragehandler = new LocalStorageHandler(this); // Display a notification about us starting. We put an icon in the status bar. conManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); //new LocalStorageHandler(this); IntentFilter i = new IntentFilter(); i.addAction("AlarmReceiver"); registerReceiver(alarmReceiver, i);/* w ww . j av a 2 s . c o m*/ }
From source file:com.android.music.ArtistAlbumBrowserFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View view = inflater.inflate(R.layout.media_picker_activity_expanding, null); getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); mToken = MusicUtils.bindToService(getActivity(), this); if (savedInstanceState != null) { mCurrentAlbumId = savedInstanceState.getString("selectedalbum"); mCurrentAlbumName = savedInstanceState.getString("selectedalbumname"); mCurrentArtistId = savedInstanceState.getString("selectedartist"); mCurrentArtistName = savedInstanceState.getString("selectedartistname"); }//from w w w. j a v a 2 s . c o m IntentFilter f = new IntentFilter(); f.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED); f.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED); f.addAction(Intent.ACTION_MEDIA_UNMOUNTED); f.addDataScheme("file"); getActivity().registerReceiver(mScanListener, f); lv = (ExpandableListView) view.findViewById(android.R.id.list); mAdapter = (ArtistAlbumListAdapter) getActivity().getLastNonConfigurationInstance(); if (mAdapter == null) { //Log.i("@@@", "starting query"); mAdapter = new ArtistAlbumListAdapter(getActivity().getApplication(), this, null, // cursor R.layout.track_list_item_group, new String[] {}, new int[] {}, R.layout.track_list_item_child, new String[] {}, new int[] {}); lv.setAdapter(mAdapter); getArtistCursor(mAdapter.getQueryHandler(), null); } else { mAdapter.setActivity(this); lv.setAdapter(mAdapter); mArtistCursor = mAdapter.getCursor(); if (mArtistCursor != null) { init(mArtistCursor); } else { getArtistCursor(mAdapter.getQueryHandler(), null); } } lv.setOnCreateContextMenuListener(this); lv.setOnChildClickListener(this); lv.setTextFilterEnabled(true); return view; }