List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.t2.androidspineexample.AndroidSpineExampleActivity.java
/** Called when the activity is first created. */ @Override/* w w w . j av a2s .c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, this.getClass().getSimpleName() + ".onCreate()"); mInstance = this; setContentView(R.layout.main); // Set up member variables to UI Elements mTextViewDataMindset = (TextView) findViewById(R.id.textViewData); mTextViewDataShimmerEcg = (TextView) findViewById(R.id.textViewDataShimmerEcg); mTextViewDataShimmerGsr = (TextView) findViewById(R.id.textViewDataShimmerGsr); mTextViewDataShimmerEmg = (TextView) findViewById(R.id.textViewDataShimmerEmg); // ---------------------------------------------------- // Initialize SPINE by passing the fileName with the configuration properties // ---------------------------------------------------- Resources resources = this.getResources(); AssetManager assetManager = resources.getAssets(); try { mSpineManager = SPINEFactory.createSPINEManager("SPINETestApp.properties", resources); } catch (InstantiationException e) { Log.e(TAG, "Exception creating SPINE manager: " + e.toString()); Log.e(TAG, "Check to see that valid defaults.properties, and SpineTestApp.properties files exist in the Assets folder!"); e.printStackTrace(); } // ... then we need to register a SPINEListener implementation to the SPINE manager instance // to receive sensor node data from the Spine server // (I register myself since I'm a SPINEListener implementation!) mSpineManager.addListener(this); // Create a broadcast receiver. Note that this is used ONLY for command messages from the service // All data from the service goes through the mail SPINE mechanism (received(Data data)). // See public void received(Data data) this.mCommandReceiver = new SpineReceiver(this); // Set up filter intents so we can receive broadcasts IntentFilter filter = new IntentFilter(); filter.addAction("com.t2.biofeedback.service.status.BROADCAST"); this.registerReceiver(this.mCommandReceiver, filter); try { mCurrentMindsetData = new MindsetData(this); } catch (Exception e1) { Log.e(TAG, "Exception creating MindsetData: " + e1.toString()); } // Since Mindset is a static node we have to manually put it in the active node list // Note that the sensor id 0xfff1 (-15) is a reserved id for this particular sensor Node MindsetNode = null; MindsetNode = new Node(new Address("" + Constants.RESERVED_ADDRESS_MINDSET)); mSpineManager.getActiveNodes().add(MindsetNode); // Since Shimmer is a static node we have to manually put it in the active node list mShimmerNode = new Node(new Address("" + Constants.RESERVED_ADDRESS_SHIMMER)); mSpineManager.getActiveNodes().add(mShimmerNode); // Set up graph(s) mSeries = new XYSeries("parameter"); generateChart(); }
From source file:com.android.music.AlbumBrowserActivity.java
@Override public void onResume() { super.onResume(); IntentFilter f = new IntentFilter(); f.addAction(MediaPlaybackService.META_CHANGED); f.addAction(MediaPlaybackService.QUEUE_CHANGED); registerReceiver(mTrackListListener, f); mTrackListListener.onReceive(null, null); MusicUtils.setSpinnerState(this); badSymptoms.resumeActivity();//from ww w .j a v a2 s. com }
From source file:com.watch.customer.ui.ShopListActivity.java
private void initRun() { // TODO Auto-generated method stub typelistRun = new Runnable() { @Override/* w ww . j a v a2 s.c om*/ public void run() { // TODO Auto-generated method stub String result = null; try { result = HttpUtil.get(HttpUtil.URL_TYPELIST); } catch (IOException e) { e.printStackTrace(); result = e.getMessage(); } Message msg = new Message(); msg.what = typelist_what; msg.obj = result; mHandler.sendMessage(msg); } }; ThreadPoolManager.getInstance().addTask(typelistRun); SearchBySec(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(REFRESH_CITY); registerReceiver(MyReceiver, intentFilter); }
From source file:com.android.music.PlaylistBrowserFragment.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, null); final Intent intent = getActivity().getIntent(); final String action = intent.getAction(); if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) { mCreateShortcut = true;/*www . j a v a2 s .c om*/ } getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); mToken = MusicUtils.bindToService(getActivity(), new ServiceConnection() { public void onServiceConnected(ComponentName classname, IBinder obj) { if (Intent.ACTION_VIEW.equals(action)) { Bundle b = intent.getExtras(); if (b == null) { Log.w(TAG, "Unexpected:getExtras() returns null."); } else { try { long id = Long.parseLong(b.getString("playlist")); if (id == RECENTLY_ADDED_PLAYLIST) { playRecentlyAdded(); } else if (id == PODCASTS_PLAYLIST) { playPodcasts(); } else if (id == ALL_SONGS_PLAYLIST) { long[] list = MusicUtils.getAllSongs(getActivity()); if (list != null) { MusicUtils.playAll(getActivity(), list, 0); } } else { MusicUtils.playPlaylist(getActivity(), id); } } catch (NumberFormatException e) { Log.w(TAG, "Playlist id missing or broken"); } } getActivity().finish(); return; } MusicUtils.updateNowPlaying(getActivity()); } public void onServiceDisconnected(ComponentName classname) { } }); 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 = (ListView) view.findViewById(android.R.id.list); lv.setOnCreateContextMenuListener(this); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub if (mCreateShortcut) { final Intent shortcut = new Intent(); shortcut.setAction(Intent.ACTION_VIEW); shortcut.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/playlist"); shortcut.putExtra("playlist", String.valueOf(id)); final Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, ((TextView) view.findViewById(R.id.line1)).getText()); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource .fromContext(getActivity(), R.drawable.ic_launcher_shortcut_music_playlist)); getActivity().setResult(getActivity().RESULT_OK, intent); getActivity().finish(); return; } if (id == RECENTLY_ADDED_PLAYLIST) { Intent intent = new Intent(Intent.ACTION_PICK); intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); intent.putExtra("playlist", "recentlyadded"); startActivity(intent); } else if (id == PODCASTS_PLAYLIST) { Intent intent = new Intent(Intent.ACTION_PICK); intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); intent.putExtra("playlist", "podcasts"); startActivity(intent); } else { Intent intent = new Intent(Intent.ACTION_EDIT); intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); intent.putExtra("playlist", Long.valueOf(id).toString()); startActivity(intent); } } }); mAdapter = (PlaylistListAdapter) getActivity().getLastNonConfigurationInstance(); if (mAdapter == null) { //Log.i("@@@", "starting query"); mAdapter = new PlaylistListAdapter(getActivity().getApplication(), this, R.layout.track_list_item, mPlaylistCursor, new String[] { MediaStore.Audio.Playlists.NAME }, new int[] { android.R.id.text1 }); lv.setAdapter(mAdapter); //setTitle(R.string.working_playlists); getPlaylistCursor(mAdapter.getQueryHandler(), null); } else { mAdapter.setActivity(this); lv.setAdapter(mAdapter); mPlaylistCursor = mAdapter.getCursor(); // If mPlaylistCursor is null, this can be because it doesn't have // a cursor yet (because the initial query that sets its cursor // is still in progress), or because the query failed. // In order to not flash the error dialog at the user for the // first case, simply retry the query when the cursor is null. // Worst case, we end up doing the same query twice. if (mPlaylistCursor != null) { init(mPlaylistCursor); } else { //setTitle(R.string.working_playlists); getPlaylistCursor(mAdapter.getQueryHandler(), null); } } return view; }
From source file:com.google.fpl.gim.examplegame.MainService.java
@Override public void onCreate() { // The service is being created. Utils.logDebug(TAG, "onCreate"); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(CHOICE_NOTIFICATION_ACTION_1); intentFilter.addAction(CHOICE_NOTIFICATION_ACTION_2); intentFilter.addAction(CHOICE_NOTIFICATION_ACTION_3); registerReceiver(mReceiver, intentFilter); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); // Determines the behavior for handling Audio Focus surrender. mAudioFocusChangeListener = new AudioManager.OnAudioFocusChangeListener() { @Override/*from w w w .ja v a 2 s.c o m*/ public void onAudioFocusChange(int focusChange) { if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT || focusChange == AudioManager.AUDIOFOCUS_LOSS) { if (mTextToSpeech.isSpeaking()) { mTextToSpeech.setOnUtteranceProgressListener(null); mTextToSpeech.stop(); } if (mMediaPlayer.isPlaying()) { mMediaPlayer.stop(); } // Abandon Audio Focus, if it's requested elsewhere. mAudioManager.abandonAudioFocus(mAudioFocusChangeListener); // Restart the current moment if AudioFocus was lost. Since AudioFocus is only // requested away from this application if this application was using it, // only Moments that play sound will restart in this way. if (mMission != null) { mMission.restartMoment(); } } } }; // Asynchronously prepares the TextToSpeech. mTextToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { // Check if language is available. switch (mTextToSpeech.isLanguageAvailable(DEFAULT_TEXT_TO_SPEECH_LOCALE)) { case TextToSpeech.LANG_AVAILABLE: case TextToSpeech.LANG_COUNTRY_AVAILABLE: case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE: Utils.logDebug(TAG, "TTS locale supported."); mTextToSpeech.setLanguage(DEFAULT_TEXT_TO_SPEECH_LOCALE); mIsTextToSpeechReady = true; break; case TextToSpeech.LANG_MISSING_DATA: Utils.logDebug(TAG, "TTS missing data, ask for install."); Intent installIntent = new Intent(); installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); startActivity(installIntent); break; default: Utils.logDebug(TAG, "TTS local not supported."); break; } } } }); mMediaPlayer = new MediaPlayer(); }
From source file:com.android.deskclock.alarms.AlarmActivity.java
@Override protected void onResume() { super.onResume(); // Re-query for AlarmInstance in case the state has changed externally final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { LogUtils.i(LOGTAG, "No alarm instance for instanceId: %d", instanceId); finish();//from www.j a v a2 s .c o m return; } // Verify that the alarm is still firing before showing the activity if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LogUtils.i(LOGTAG, "Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } if (!mReceiverRegistered) { // Register to get the alarm done/snooze/dismiss intent. final IntentFilter filter = new IntentFilter(AlarmService.ALARM_DONE_ACTION); filter.addAction(AlarmService.ALARM_SNOOZE_ACTION); filter.addAction(AlarmService.ALARM_DISMISS_ACTION); registerReceiver(mReceiver, filter); mReceiverRegistered = true; } bindAlarmService(); resetAnimations(); }
From source file:io.teak.sdk.Session.java
private Session(AppConfiguration appConfiguration, DeviceConfiguration deviceConfiguration) { // State: Created // Valid data: // - startDate // - appConfiguration // - deviceConfiguration this.startDate = new Date(); this.appConfiguration = appConfiguration; this.deviceConfiguration = deviceConfiguration; DeviceConfiguration.addEventListener(this.deviceConfigurationListener); IntentFilter filter = new IntentFilter(); filter.addAction(FacebookAccessTokenBroadcast.UPDATED_ACCESS_TOKEN_INTENT_ACTION); Teak.localBroadcastManager.registerReceiver(this.facebookBroadcastReceiver, filter); setState(State.Created);// w w w.j a v a2 s . c o m }
From source file:com.android.music.ArtistAlbumBrowserFragment.java
@Override public void onResume() { // TODO Auto-generated method stub super.onResume(); IntentFilter f = new IntentFilter(); f.addAction(MediaPlaybackService.META_CHANGED); f.addAction(MediaPlaybackService.QUEUE_CHANGED); getActivity().registerReceiver(mTrackListListener, f); mTrackListListener.onReceive(null, null); //need fix// w w w . ja va 2s . c om MusicUtils.setSpinnerState(getActivity()); }
From source file:com.dwdesign.tweetings.fragment.BaseStatusesListFragment.java
@Override public void onStart() { super.onStart(); mTickerStopped = false;/* w w w .ja v a2 s . c om*/ mHandler = new Handler(); mTicker = new Runnable() { @Override public void run() { if (mTickerStopped) return; if (mListView != null && !mBusy) { getListAdapter().notifyDataSetChanged(); } final long now = SystemClock.uptimeMillis(); final long next = now + TICKER_DURATION - now % TICKER_DURATION; mHandler.postAtTime(mTicker, next); } }; mTicker.run(); final IntentFilter filter = new IntentFilter(); filter.addAction(BROADCAST_MULTI_SELECT_STATE_CHANGED); filter.addAction(BROADCAST_MULTI_SELECT_ITEM_CHANGED); registerReceiver(mStateReceiver, filter); onPostStart(); }
From source file:com.jacr.instagramtrendreader.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.activity_main); /* Customizing ActionBar */ Resources r = getResources(); ActionBar ab = super.getActionBar(false); ab.setIcon(r.getDrawable(R.drawable.ic_menu_home)); ab.setTitle(Util.getTitleActivity(getString(R.string.title_my_gallery_app))); /* Views *///from w ww . j ava 2s . c om layoutThumbnail = (TableLayout) findViewById(R.id.layoutThumbnail); layoutThumbnail.setPadding(1, 1, 1, 1); /* Setting Viewpager and Indicator */ mPager = (ViewPager) findViewById(R.id.pagerMain); mAdapter = new ViewPagerAdapter<MainFragment>(getSupportFragmentManager()); mPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(int arg0) { int key = feedReader.getListThumbnailKeys().get(arg0); feedReader.highlightThumbnail(key); } }); /* Receiver */ mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras(); if (action.contentEquals(ACTION_IMAGE_CLICK)) { int key = extras.getInt(ACTION_IMAGE_CLICK); if (key != -1) { Intent in = new Intent(Main.this, ImageDetails.class); Bundle b = new Bundle(); /* * Warning with Error FAILED BINDED TRANSACTION: it * happens When the transfer of "extras" out of memory. * in This case, when images are sent in intent. */ b.putSerializable(ImageDetails.KEY_THUMBNAIL_DATA, feedReader.getListThumbnailData()); b.putSerializable(ImageDetails.KEY_THUMBNAIL_KEYS, feedReader.getListThumbnailKeys()); b.putInt(ImageDetails.KEY_THUMBNAIL_ACTUAL_KEY, key); in.putExtras(b); startActivity(in); } } } }; IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_IMAGE_CLICK); registerReceiver(mReceiver, filter); /* Load data from Instagram */ cargarFeedReader(); }