List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.dsna.android.main.MainActivity.java
@Override protected void onResume() { super.onResume(); Intent intent = new Intent(this, AndroidSocialService.class); intent.putExtra(bIp, mBootIp);/*w w w . j a va 2 s . c o m*/ intent.putExtra(bPort, mBootPort); intent.putExtra(biPort, mBindPort); intent.putExtra(uName, mUsername); LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(AndroidSocialService.RECEIVE_ENTITY); intentFilter.addAction(AndroidSocialService.DISPLAY_TOAST); bManager.registerReceiver(bReceiver, intentFilter); System.out.println("Prepare to bind service"); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); }
From source file:org.linphone.LinphoneService.java
void addCallListner() { mIncomingCallReceiver = new IncomingCallReceiver(); IntentFilter mIntentFilter = new IntentFilter(); // //from w ww . j a va 2s . co m mIntentFilter.addAction("android.intent.action.PHONE_STATE"); mIntentFilter.setPriority(1000); // // mIntentFilter.addAction("android.provider.Telephony.SMS_RECEIVED"); // BroadcastReceiver registerReceiver(mIncomingCallReceiver, mIntentFilter); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); // endcall TelephonyManager mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); try { Method getITelephonyMethod = TelephonyManager.class.getDeclaredMethod("getITelephony", (Class[]) null); getITelephonyMethod.setAccessible(true); // mITelephony = (ITelephony) getITelephonyMethod.invoke(mTelephonyManager, (Object[]) null); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.android.music.MusicBrowserActivity.java
public void onCreateContinue(Bundle savedInstanceState) { MusicLogUtils.d(TAG, "onCreate"); ActionBar actionBar = getActionBar(); actionBar.hide();//from w w w.ja v a 2 s . co m setVolumeControlStream(AudioManager.STREAM_MUSIC); PDebug.Start("MusicBrowserActivity.bindToService()"); mToken = MusicUtils.bindToService(this, this); PDebug.End("MusicBrowserActivity.bindToService()"); mMusicPlugin = Extensions.getPluginObject(getApplicationContext()); mHasMenukey = ViewConfiguration.get(this).hasPermanentMenuKey(); PDebug.Start("MusicBrowserActivity.dispatchCreate()"); mActivityManager = new LocalActivityManager(this, false); mActivityManager.dispatchCreate(savedInstanceState); PDebug.End("MusicBrowserActivity.dispatchCreate()"); mTabHost = getTabHost(); PDebug.Start("MusicBrowserActivity.initTab()"); initTab(); PDebug.End("MusicBrowserActivity.initTab()"); PDebug.Start("MusicBrowserActivity.setCurrentTab()"); mCurrentTab = MusicUtils.getIntPref(this, SAVE_TAB, ARTIST_INDEX); MusicLogUtils.d(TAG, "onCreate mCurrentTab: " + mCurrentTab); if ((mCurrentTab < 0) || (mCurrentTab >= mTabCount)) { mCurrentTab = ARTIST_INDEX; } /// M: reset the defalt tab value if (mCurrentTab == ARTIST_INDEX) { mTabHost.setCurrentTab(ALBUM_INDEX); } mTabHost.setOnTabChangedListener(this); PDebug.End("MusicBrowserActivity.setCurrentTab()"); PDebug.Start("MusicBrowserActivity.initPager()"); initPager(); PDebug.End("MusicBrowserActivity.initPager()"); PDebug.Start("MusicBrowserActivity.setAdapter()"); mViewPager = (ViewPager) findViewById(R.id.viewpage); mViewPager.setAdapter(new MusicPagerAdapter()); mViewPager.setOnPageChangeListener(this); //mViewPager.setOffscreenPageLimit(VIEW_PAGER_OFFSCREEN_PAGE_NUM); PDebug.End("MusicBrowserActivity.setAdapter()"); IntentFilter f = new IntentFilter(); f.addAction(MusicUtils.SDCARD_STATUS_UPDATE); registerReceiver(mSdcardstatustListener, f); createFakeMenu(); /// M: Init search button click listener in nowplaying. initSearchButton(); PDebug.End("MusicBrowserActivity.onCreate"); }
From source file:cc.mintcoin.wallet.service.BlockchainServiceImpl.java
private void startBlockChain() { if (blockChain != null) return;/*from w w w.j a va 2 s. c o m*/ final Wallet wallet = application.getWallet(); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); 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); boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { log.info("blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); wallet.setLastBlockSeenHeight(-1); // magic value wallet.setLastBlockSeenHash(null); } try { blockStore = new TxTrackingBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); blockStore.getChainHead(); // detect corruptions as early as possible final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); } catch (final BlockStoreException x) { deleteBlockChainFile(); final String msg = "blockstore cannot be created"; log.error(msg, x); throw new Error(msg, x); } log.info("using " + blockStore.getClass().getName()); try { blockChain = new TxTrackingBlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener, Threading.SAME_THREAD); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); maybeRotateKeys(); return; }
From source file:com.java2s.intents4.IntentsDemo4Activity.java
private IntentFilter createFilterFromEditTextFields() { IntentFilter filter = new IntentFilter(); if (filterActionsLayout != null) { int count = filterActionsLayout.getChildCount(); for (int i = 0; i < count; i++) { String action = ((EditText) ((ViewGroup) filterActionsLayout.getChildAt(i)).getChildAt(1)).getText() .toString().trim();/*from w w w. java 2s .c om*/ if (action.length() != 0) { filter.addAction(action); } } } if (filterSchemeLayout != null) { int count = filterSchemeLayout.getChildCount(); for (int i = 0; i < count; i++) { String scheme = ((EditText) ((ViewGroup) filterSchemeLayout.getChildAt(i)).getChildAt(1)).getText() .toString().trim(); if (scheme.length() != 0) { filter.addDataScheme(scheme); } } } if (filterAuthLayout != null) { int count = filterAuthLayout.getChildCount(); for (int i = 0; i < count; i++) { String auth = ((EditText) ((ViewGroup) filterAuthLayout.getChildAt(i)).getChildAt(1)).getText() .toString().trim(); if (auth.length() != 0) { Scanner scanner = new Scanner(auth); scanner.useDelimiter(":"); String host = null; String port = null; if (scanner.hasNext()) { host = scanner.next(); } if (scanner.hasNext()) { port = scanner.next(); } filter.addDataAuthority(host, port); } } } if (filterPathLayout != null) { int count = filterPathLayout.getChildCount(); for (int i = 0; i < count; i++) { ViewGroup group = (ViewGroup) filterPathLayout.getChildAt(i); String path = ((EditText) group.getChildAt(1)).getText().toString().trim(); String pattern = ((TextView) ((ViewGroup) group.getChildAt(2)).getChildAt(0)).getText().toString() .trim(); // ((TextView) int patternInt = 0; if (pattern.equals(pathPatterns[0])) { patternInt = PatternMatcher.PATTERN_LITERAL; } if (pattern.equals(pathPatterns[1])) { patternInt = PatternMatcher.PATTERN_PREFIX; } if (pattern.equals(pathPatterns[2])) { patternInt = PatternMatcher.PATTERN_SIMPLE_GLOB; } if (path.length() != 0) { filter.addDataPath(path, patternInt); } } } if (filterTypeLayout != null) { int count = filterTypeLayout.getChildCount(); for (int i = 0; i < count; i++) { String aType = ((EditText) ((ViewGroup) filterTypeLayout.getChildAt(i)).getChildAt(1)).getText() .toString().trim(); if (aType.length() != 0) { try { filter.addDataType(aType); } catch (MalformedMimeTypeException e) { e.printStackTrace(); } } } } if (filterCategoriesLayout != null) { int count = filterCategoriesLayout.getChildCount(); for (int i = 0; i < count; i++) { String cat = ((EditText) ((ViewGroup) filterCategoriesLayout.getChildAt(i)).getChildAt(1)).getText() .toString().trim(); if (cat.length() != 0) { filter.addCategory(cat); } } } return filter; }
From source file:com.dwdesign.tweetings.fragment.StatusFragment.java
@Override public void onStart() { super.onStart(); final IntentFilter filter = new IntentFilter(); filter.addAction(BROADCAST_FRIENDSHIP_CHANGED); filter.addAction(BROADCAST_FAVORITE_CHANGED); filter.addAction(BROADCAST_RETWEET_CHANGED); filter.addAction(BROADCAST_TWITLONGER_EXPANDED); registerReceiver(mStatusReceiver, filter); if (mStatus != null) { displayStatus(mStatus);/*from ww w . j a v a2s . c om*/ } else { getStatus(false); } updateUserColor(); }
From source file:com.example.android.home.Home.java
/** * Registers various intent receivers. The current implementation registers * only a wallpaper intent receiver to let other applications change the * wallpaper.//www . j a v a 2s . c o m */ private void registerIntentReceivers() { IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED); registerReceiver(mWallpaperReceiver, filter); filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_CHANGED); filter.addDataScheme("package"); registerReceiver(mApplicationsReceiver, filter); }
From source file:org.linphone.LinphoneService.java
@Override public void onCreate() { super.onCreate(); theLinphone = this; // Dump some debugging information to the logs Hacks.dumpDeviceInformation();/* ww w. j a v a 2 s . c o m*/ addCallListner(); // tryTogetLastReceive(); // tryTogetLastRequest(); tryKeepOnline(); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotification = new Notification(R.drawable.status_level, "", System.currentTimeMillis()); mNotification.iconLevel = IC_LEVEL_ORANGE; mNotification.flags |= Notification.FLAG_ONGOING_EVENT; Intent notificationIntent = new Intent(this, MainViewActivity.class); mNofificationContentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mNotification.setLatestEventInfo(this, NOTIFICATION_TITLE, "", mNofificationContentIntent); mNotificationManager.notify(NOTIFICATION_ID, mNotification); mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); mAudioManager = ((AudioManager) getSystemService(Context.AUDIO_SERVICE)); mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); try { copyAssetsFromPackage(); mLinphoneCore = LinphoneCoreFactory.instance().createLinphoneCore(this, LINPHONE_RC, LINPHONE_FACTORY_RC, null); mLinphoneCore.setPlaybackGain(3); mLinphoneCore.setRing(null); try { initFromConf(); } catch (LinphoneException e) { Log.w(TAG, "no config ready yet"); } TimerTask lTask = new TimerTask() { @Override public void run() { mLinphoneCore.iterate(); } }; mTimer.scheduleAtFixedRate(lTask, 0, 100); IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); lFilter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(mKeepAliveMgrReceiver, lFilter); } catch (Exception e) { Log.e(TAG, "Cannot start linphone", e); } }
From source file:com.boko.vimusic.ui.activities.AudioPlayerActivity.java
/** * {@inheritDoc}/*from w ww. j ava2 s . c om*/ */ @Override protected void onStart() { super.onStart(); final IntentFilter filter = new IntentFilter(); // Play and pause changes filter.addAction(MediaPlaybackService.EVENT_PLAYSTATE_CHANGED); // Shuffle and repeat changes filter.addAction(MediaPlaybackService.EVENT_SHUFFLEMODE_CHANGED); filter.addAction(MediaPlaybackService.EVENT_REPEATMODE_CHANGED); // Track changes filter.addAction(MediaPlaybackService.EVENT_META_CHANGED); registerReceiver(mPlaybackStatus, filter); // Refresh the current time final long next = refreshCurrentTime(); queueNextRefresh(next); MusicUtils.notifyForegroundStateChanged(this, true); }
From source file:com.android.mms.ui.ConversationList.java
@Override protected void onStart() { super.onStart(); if (notDeleting) { MessagingNotification.cancelNotification(getApplicationContext(), SmsRejectedReceiver.SMS_REJECTED_NOTIFICATION_ID); DraftCache.getInstance().addOnDraftChangedListener(this); Intent it = getIntent();/*from ww w .j a v a2 s. c o m*/ Bundle bundle = it.getExtras(); if (bundle != null) { fromFolder = bundle.getBoolean("fromFolder", false); } if (fromFolder) { mNeedToMarkAsSeen = false; } else { mNeedToMarkAsSeen = true; } int dropNum = Conversation.cleanExpiredWapPush(this); if (0 < dropNum) { Toast.makeText(this, getResources().getString(R.string.dl_expired_wap_push, dropNum), Toast.LENGTH_LONG).show(); } startAsyncQuery(); // We used to refresh the DraftCache here, but // refreshing the DraftCache each time we go to the ConversationList seems overly // aggressive. We already update the DraftCache when leaving CMA in onStop() and // onNewIntent(), and when we delete threads or delete all in CMA or this activity. // I hope we don't have to do such a heavy operation each time we enter here. // we invalidate the contact cache here because we want to get updated presence // and any contact changes. We don't invalidate the cache by observing presence and contact // changes (since that's too untargeted), so as a tradeoff we do it here. // If we're in the middle of the app initialization where we're loading the conversation // threads, don't invalidate the cache because we're in the process of building it. // TODO: think of a better way to invalidate cache more surgically or based on actual // TODO: changes we care about if (!Conversation.loadingThreads()) { Contact.invalidateCache(); } // Listen for broadcast intents that indicate the SMS is ready IntentFilter filter = new IntentFilter(TelephonyIntents.ACTION_IS_SIM_SMS_READY); //===== fixed CR<NEWMS00127040> by luning at 11-10-07 begin ===== filter.addAction(TelephonyIntents.ACTION_IS_SIM_SMS_READY1); registerReceiver(mReceiver, filter); } }