List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.anyonavinfo.commonuserregister.MainActivity.java
/** * // w w w.j av a 2s.c o m */ private void registerReceiver() { checkReceiver = new CheckReceiver(); IntentFilter messageFilter = new IntentFilter(); messageFilter.addAction(CommonData.MESSAGE_NAME_NULL); messageFilter.addAction(CommonData.MESSAGE_NAME_WRONG); messageFilter.addAction(CommonData.MESSAGE_MOBILE_NULL); messageFilter.addAction(CommonData.MESSAGE_MOBILE_WRONG); messageFilter.addAction(CommonData.MESSAGE_4S_NULL); messageFilter.addAction(CommonData.MESSAGE_VIN_NULL); messageFilter.addAction(CommonData.MESSAGE_VIN_WRONG); messageFilter.addAction(CommonData.MESSAGE_BIRTHDAY_NULL); messageFilter.addAction(CommonData.MESSAGE_EMAIL_NULL); messageFilter.addAction(CommonData.MESSAGE_EMAIL_WRONG); messageFilter.addAction(CommonData.MESSAGE_NICK_WRONG); messageFilter.addAction(CommonData.MESSAGE_NICK_NULL); messageFilter.addAction(CommonData.MESSAGE_TYPE_NULL); registerReceiver(checkReceiver, messageFilter); }
From source file:com.example.alyshia.customsimplelauncher.MainActivity.java
public void setkioskReceiver() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(KioskMode.ACTION_ENABLE_KIOSK_MODE_RESULT); intentFilter.addAction(KioskMode.ACTION_DISABLE_KIOSK_MODE_RESULT); if (kioskReceiver == null) { kioskReceiver = new KioskReceiver(this, MainActivity.this); HandlerThread handlerThread = new HandlerThread("DifferentThread", Process.THREAD_PRIORITY_BACKGROUND); handlerThread.start();//from ww w.j a v a2s . c o m Looper looper = handlerThread.getLooper(); kioskHandler = new Handler(looper, this); registerReceiver(kioskReceiver, intentFilter, null, kioskHandler); } }
From source file:com.feathercoin.wallet.feathercoin.service.BlockchainServiceImpl.java
@Override public void onCreate() { Log.d(TAG, ".onCreate()"); super.onCreate(); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, lockName); wifiLock.setReferenceCounted(false); application = (WalletApplication) getApplication(); prefs = PreferenceManager.getDefaultSharedPreferences(this); final Wallet wallet = application.getWallet(); final int versionCode = application.applicationVersionCode(); prefs.edit().putInt(Constants.PREFS_KEY_LAST_VERSION, versionCode).commit(); bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0);// ww w. j a va 2 s .c o m final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); blockChainFile = new File(getDir("blockstore", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE), Constants.BLOCKCHAIN_FILENAME); final boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { Log.d(TAG, "blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); copyBlockchainSnapshot(blockChainFile); } try { blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); if (!blockChainFileExists) { // Starting from scratch try { final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); final InputStream checkpointsFileIn = getAssets().open("checkpoints"); CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsFileIn, blockStore, earliestKeyCreationTime); } catch (IOException e) { Log.d("Feathercoin", "Couldn't find checkpoints file; starting from genesis"); } } blockStore.getChainHead(); // detect corruptions as early as possible } catch (final BlockStoreException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } catch (final NullPointerException x) { blockChainFile.delete(); x.printStackTrace(); throw new Error("blockstore cannot be created", x); } try { blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); }
From source file:de.mangelow.throughput.NotificationService.java
@Override public void onCreate() { super.onCreate(); if (D)/*from ww w.j a v a 2 s. c o m*/ Log.d(TAG, "Service started"); context = getApplicationContext(); res = context.getResources(); if (tmanager == null) { tmanager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tmanager.listen(new MyPhoneStateListener(), PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); } IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(mBroadcastReceiver, filter); int[] refresh_values = res.getIntArray(R.array.refresh_values); long refresh = (long) refresh_values[MainActivity.loadIntPref(context, MainActivity.REFRESH, MainActivity.REFRESH_DEFAULT)]; modifyNotification(R.drawable.ic_stat_zero, null, "", "", new Intent()); if (handler == null) { handler = new Handler(); handler.postDelayed(mRunnable, refresh); } }
From source file:com.marvin.rocklock.RockLockActivity.java
@Override public void onResume() { super.onResume(); // Poke application mPoked = false;//from ww w . jav a 2 s .c om new Thread(new PokeWatcher()).start(); // Restore music mPlayer.getNavigator().restore(); // Register headphone receiver IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_BUTTON); filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); registerReceiver(mMediaButtonReceiver, filter); }
From source file:com.android.mms.transaction.MessagingNotification.java
public static void init(Context context) { // set up the intent filter for notification deleted action IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(NOTIFICATION_DELETED_ACTION); // TODO: should we unregister when the app gets killed? context.registerReceiver(sNotificationDeletedReceiver, intentFilter); sPduPersister = PduPersister.getPduPersister(context); // initialize the notification deleted action sNotificationOnDeleteIntent = new Intent(NOTIFICATION_DELETED_ACTION); sScreenDensity = context.getResources().getDisplayMetrics().density; }
From source file:com.ieeton.agency.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //?//from w w w.ja v a 2 s .c om // UmengUpdateAgent.update(this); setContentView(R.layout.activity_main); initView(); //Ieeton IntentFilter intentfilter = new IntentFilter(); intentfilter.addAction(Constants.NEED_RELOGIN_ACTION); mIeetonReceiver = new IeetonReceiver(); registerReceiver(mIeetonReceiver, intentfilter); inviteMessgeDao = new InviteMessgeDao(this); userDao = new UserDao(this); // fragment int index = getIntent().getIntExtra(INPUT_INDEX, INPUT_CHAT_HISTORY); Utils.logd("oncreate index:" + index); // if (TextUtils.isEmpty(Utils.getPassport(this))) { index = INPUT_CONTACTLIST; } showDefaultTab(index); // ?BroadcastReceiver msgReceiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); intentFilter.setPriority(3); registerReceiver(msgReceiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(3); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ?BroadcastReceiver // IntentFilter offlineMessageIntentFilter = new IntentFilter(EMChatManager.getInstance() // .getOfflineMessageBroadcastAction()); // registerReceiver(offlineMessageReceiver, offlineMessageIntentFilter); // setContactListener??? EMContactManager.getInstance().setContactListener(new MyContactListener()); // ??listener EMChatManager.getInstance().addConnectionListener(new MyConnectionListener()); // ?listener EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener()); // sdkUI ??receiverlistener, ??broadcast EMChat.getInstance().setAppInited(); }
From source file:com.andryr.musicplayer.MainActivity.java
@Override protected void onResume() { super.onResume(); if (!mServiceBound) { mServiceIntent = new Intent(this, PlaybackService.class); bindService(mServiceIntent, mServiceConnection, BIND_AUTO_CREATE); startService(mServiceIntent);//from w w w . ja va 2 s . com IntentFilter filter = new IntentFilter(); filter.addAction(PlaybackService.META_CHANGED); filter.addAction(PlaybackService.PLAYSTATE_CHANGED); filter.addAction(PlaybackService.POSITION_CHANGED); filter.addAction(PlaybackService.ITEM_ADDED); filter.addAction(PlaybackService.ORDER_CHANGED); registerReceiver(mServiceListener, filter); } else { updateAll(); } }
From source file:com.frostwire.android.gui.fragments.MyFilesFragment.java
private void initBroadcastReceiver() { final IntentFilter filter = new IntentFilter(); filter.addAction(Constants.ACTION_REFRESH_FINGER); filter.addAction(Constants.ACTION_MEDIA_PLAYER_PLAY); filter.addAction(Constants.ACTION_MEDIA_PLAYER_PAUSED); filter.addAction(Constants.ACTION_MEDIA_PLAYER_STOPPED); filter.addAction(Constants.ACTION_FILE_ADDED_OR_REMOVED); filter.addAction(MusicPlaybackService.META_CHANGED); filter.addAction(MusicPlaybackService.PLAYSTATE_CHANGED); filter.addAction(MusicPlaybackService.SIMPLE_PLAYSTATE_STOPPED); getActivity().registerReceiver(broadcastReceiver, filter); }
From source file:com.cyanogenmod.eleven.ui.fragments.AudioPlayerFragment.java
@Override public void onStart() { super.onStart(); final IntentFilter filter = new IntentFilter(); // Play and pause changes filter.addAction(MusicPlaybackService.PLAYSTATE_CHANGED); // Shuffle and repeat changes filter.addAction(MusicPlaybackService.SHUFFLEMODE_CHANGED); filter.addAction(MusicPlaybackService.REPEATMODE_CHANGED); // Track changes filter.addAction(MusicPlaybackService.META_CHANGED); // Update a list, probably the playlist fragment's filter.addAction(MusicPlaybackService.REFRESH); // Listen to changes to the entire queue filter.addAction(MusicPlaybackService.QUEUE_CHANGED); // Listen for lyrics text for the audio track filter.addAction(MusicPlaybackService.NEW_LYRICS); // Register the intent filters getActivity().registerReceiver(mPlaybackStatus, filter); // Refresh the current time final long next = refreshCurrentTime(); queueNextRefresh(next);/* w w w .j a v a2 s . co m*/ // resumes the update callback for the play pause progress button mPlayPauseProgressButton.resume(); mEqualizerView.onStart(); }