List of usage examples for android.media AudioManager STREAM_MUSIC
int STREAM_MUSIC
To view the source code for android.media AudioManager STREAM_MUSIC.
Click Source Link
From source file:com.andrew.apollo.ui.activities.SearchActivity.java
/** * {@inheritDoc}// ww w . ja v a 2 s. c om */ @SuppressWarnings("deprecation") @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Title bar shows up in gingerbread, I'm too tired to figure out why. if (!ApolloUtils.hasHoneycomb()) { requestWindowFeature(Window.FEATURE_NO_TITLE); } // Initialze the theme resources mResources = new ThemeUtils(this); // Set the overflow style mResources.setOverflowStyle(this); // Fade it in overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); // Control the media volume setVolumeControlStream(AudioManager.STREAM_MUSIC); // Bind Apollo's service mToken = MusicUtils.bindToService(this, this); // Theme the action bar final ActionBar actionBar = getSupportActionBar(); mResources.themeActionBar(actionBar, getString(R.string.app_name)); actionBar.setDisplayHomeAsUpEnabled(true); // Set the layout setContentView(R.layout.grid_base); // Give the background a little UI final FrameLayout background = (FrameLayout) findViewById(R.id.grid_base_container); background.setBackgroundDrawable(getResources().getDrawable(R.drawable.pager_background)); // Get the query final String query = getIntent().getStringExtra(SearchManager.QUERY); mFilterString = !TextUtils.isEmpty(query) ? query : null; // Action bar subtitle mResources.setSubtitle("\"" + mFilterString + "\""); // Initialize the adapter mAdapter = new SearchAdapter(this); // Set the prefix mAdapter.setPrefix(mFilterString); // Initialze the list mGridView = (GridView) findViewById(R.id.grid_base); // Bind the data mGridView.setAdapter(mAdapter); // Recycle the data mGridView.setRecyclerListener(new RecycleHolder()); // Seepd up scrolling mGridView.setOnScrollListener(this); mGridView.setOnItemClickListener(this); if (ApolloUtils.isLandscape(this)) { mGridView.setNumColumns(TWO); } else { mGridView.setNumColumns(ONE); } // Prepare the loader. Either re-connect with an existing one, // or start a new one. getSupportLoaderManager().initLoader(0, null, this); }
From source file:com.android.music.MediaPlaybackActivity.java
/** Called when the activity is first created. */ @Override/*from w ww . j a v a2 s .co m*/ public void onCreate(Bundle icicle) { super.onCreate(icicle); setVolumeControlStream(AudioManager.STREAM_MUSIC); mAlbumArtWorker = new Worker("album art worker"); mAlbumArtHandler = new AlbumArtHandler(mAlbumArtWorker.getLooper()); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.audio_player); mCurrentTime = (TextView) findViewById(R.id.currenttime); mTotalTime = (TextView) findViewById(R.id.totaltime); mProgress = (ProgressBar) findViewById(android.R.id.progress); mAlbum = (ImageView) findViewById(R.id.album); mArtistName = (TextView) findViewById(R.id.artistname); mAlbumName = (TextView) findViewById(R.id.albumname); mTrackName = (TextView) findViewById(R.id.trackname); View v = (View) mArtistName.getParent(); v.setOnTouchListener(this); v.setOnLongClickListener(this); v = (View) mAlbumName.getParent(); v.setOnTouchListener(this); v.setOnLongClickListener(this); v = (View) mTrackName.getParent(); v.setOnTouchListener(this); v.setOnLongClickListener(this); mPrevButton = (RepeatingImageButton) findViewById(R.id.prev); mPrevButton.setOnClickListener(mPrevListener); mPrevButton.setRepeatListener(mRewListener, 260); mPauseButton = (ImageButton) findViewById(R.id.pause); mPauseButton.requestFocus(); mPauseButton.setOnClickListener(mPauseListener); mNextButton = (RepeatingImageButton) findViewById(R.id.next); mNextButton.setOnClickListener(mNextListener); mNextButton.setRepeatListener(mFfwdListener, 260); seekmethod = 1; mDeviceHasDpad = (getResources().getConfiguration().navigation == Configuration.NAVIGATION_DPAD); mQueueButton = (ImageButton) findViewById(R.id.curplaylist); mQueueButton.setOnClickListener(mQueueListener); mShuffleButton = ((ImageButton) findViewById(R.id.shuffle)); mShuffleButton.setOnClickListener(mShuffleListener); mRepeatButton = ((ImageButton) findViewById(R.id.repeat)); mRepeatButton.setOnClickListener(mRepeatListener); if (mProgress instanceof SeekBar) { SeekBar seeker = (SeekBar) mProgress; seeker.setOnSeekBarChangeListener(mSeekListener); } mProgress.setMax(1000); mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop(); badSymptoms = new BadSymptoms(this); }
From source file:com.everyplay.android.everyplayrecord.EveryplayRecordActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create a GLSurfaceView instance and set it // as the ContentView for this Activity mGLView = new EveryplayRecordSurfaceView(this); setContentView(mGLView);//from w w w. j a va 2 s.co m buttons = new LinearLayout(this); buttons.setOrientation(LinearLayout.VERTICAL); if (!USE_EVERYPLAY_AUDIO_BOARD) { addButton("Everyplay", "everyplay"); addButton("Start recording", "rec"); Button playLastRecording = addButton("Play last recording", "play_last_recording"); playLastRecording.setVisibility(View.GONE); addButton("Test video playback", "test_video_playback"); addButton("Show sharing modal", "sharing_modal"); Button hudRecord = addButton("HUD record off", "hud_record"); hudRecord.setVisibility(View.GONE); stream1 = new EveryplayRecordAudioGenerator(5); stream1.play(); streamActive = stream1; } else { addButton("Play song #1", "play1_a"); addButton("Unload song #1", "unload1_a"); addButton("Pause song", "pause_a"); addButton("Resume song", "resume_a"); addButton("Rewind song", "rewind_a"); addButton("Stop song", "stop_a"); this.addContentView(buttons, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); buttons = new LinearLayout(this); buttons.setOrientation(LinearLayout.VERTICAL); buttons.setX(400); addButton("Play song #2", "play2_a"); addButton("Unload song #2", "unload2_a"); addButton("Effect #1", "effect1_a"); addButton("Effect #2", "effect2_a"); addButton("Start recording", "rec"); addButton("Play last recording", "play_last_recording"); soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); sound_pew = soundPool.load(this, R.raw.pew, 1); sound_pow = soundPool.load(this, R.raw.pow, 1); } this.addContentView(buttons, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); init(); }
From source file:com.andreadec.musicplayer.MainActivity.java
@SuppressLint({ "InlinedApi", "NewApi" }) @Override//from w ww. j av a2 s.co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setVolumeControlStream(AudioManager.STREAM_MUSIC); preferences = PreferenceManager.getDefaultSharedPreferences(this); if (preferences.getBoolean(Constants.PREFERENCE_DISABLELOCKSCREEN, Constants.DEFAULT_DISABLELOCKSCREEN)) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // Disable lock screen for this activity } requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); if (preferences.getBoolean(Constants.PREFERENCE_SHOWHELPOVERLAYMAINACTIVITY, true)) { final FrameLayout frameLayout = new FrameLayout(this); LayoutInflater layoutInflater = getLayoutInflater(); layoutInflater.inflate(R.layout.layout_main, frameLayout); layoutInflater.inflate(R.layout.layout_helpoverlay_main, frameLayout); final View overlayView = frameLayout.getChildAt(1); overlayView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { frameLayout.removeView(overlayView); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean(Constants.PREFERENCE_SHOWHELPOVERLAYMAINACTIVITY, false); editor.commit(); } }); setContentView(frameLayout); } else { setContentView(R.layout.layout_main); } pages = new String[4]; pages[PAGE_BROWSER] = getResources().getString(R.string.browser); pages[PAGE_PLAYLISTS] = getResources().getString(R.string.playlist); pages[PAGE_RADIOS] = getResources().getString(R.string.radio); pages[PAGE_PODCASTS] = getResources().getString(R.string.podcasts); fragmentManager = getSupportFragmentManager(); setTitle(pages[currentPage]); /* NAVIGATION DRAWER */ drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); setTitle(pages[currentPage]); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); setTitle(getResources().getString(R.string.app_name)); } }; drawerLayout.setDrawerListener(drawerToggle); if (Build.VERSION.SDK_INT >= 11) getActionBar().setDisplayHomeAsUpEnabled(true); drawerContainer = (RelativeLayout) findViewById(R.id.navigation_container); drawerList = (ListView) findViewById(R.id.navigation_list); navigationAdapter = new NavigationDrawerArrayAdapter(this, pages); drawerList.setAdapter(navigationAdapter); drawerList.setOnItemClickListener(new ListView.OnItemClickListener() { @Override public void onItemClick(@SuppressWarnings("rawtypes") AdapterView parent, View view, int position, long id) { openPage(position); drawerLayout.closeDrawer(drawerContainer); } }); buttonQuit = findViewById(R.id.navigation_buttonQuit); buttonQuit.setOnClickListener(this); if (Build.VERSION.SDK_INT >= 19) { // Android 4.4+ only boolean translucentStatus = preferences.getBoolean(Constants.PREFERENCE_TRANSLUCENTSTATUSBAR, Constants.DEFAULT_TRANSLUCENTSTATUSBAR); boolean translucentNavigation = preferences.getBoolean(Constants.PREFERENCE_TRANSLUCENTNAVIGATIONBAR, Constants.DEFAULT_TRANSLUCENTNAVIGATIONBAR); if (translucentStatus) getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS); if (translucentNavigation) getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); SystemBarTintManager tintManager = new SystemBarTintManager(this); if (translucentStatus) { tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(R.color.actionBarBackground); } } textViewArtist = (TextView) findViewById(R.id.textViewArtist); textViewTitle = (TextView) findViewById(R.id.textViewTitle); textViewTime = (TextView) findViewById(R.id.textViewTime); imageViewSongImage = (ImageView) findViewById(R.id.imageViewSongImage); imageButtonPrevious = (ImageButton) findViewById(R.id.imageButtonPrevious); imageButtonPlayPause = (ImageButton) findViewById(R.id.imageButtonPlayPause); imageButtonNext = (ImageButton) findViewById(R.id.imageButtonNext); seekBar1 = (SeekBar) findViewById(R.id.seekBar1); seekBar2 = (SeekBar) findViewById(R.id.seekBar2); imageButtonShowSeekbar2 = (ImageButton) findViewById(R.id.imageButtonShowSeekbar2); imageButtonShuffle = (ImageButton) findViewById(R.id.imageButtonShuffle); imageButtonRepeat = (ImageButton) findViewById(R.id.imageButtonRepeat); imageButtonRepeatAll = (ImageButton) findViewById(R.id.imageButtonRepeatAll); buttonBassBoost = (Button) findViewById(R.id.buttonBassBoost); buttonEqualizer = (Button) findViewById(R.id.buttonEqualizer); buttonShake = (Button) findViewById(R.id.buttonShake); imageButtonShuffle.setOnClickListener(this); imageButtonRepeat.setOnClickListener(this); imageButtonRepeatAll.setOnClickListener(this); buttonBassBoost.setOnClickListener(this); buttonEqualizer.setOnClickListener(this); buttonShake.setOnClickListener(this); imageButtonShowSeekbar2.setOnClickListener(this); imageButtonPrevious.setOnClickListener(this); imageButtonPlayPause.setOnClickListener(this); imageButtonNext.setOnClickListener(this); seekBar1.setOnSeekBarChangeListener(this); seekBar1.setClickable(false); seekBar2.setOnSeekBarChangeListener(this); textViewTime.setOnClickListener(this); showSongImage = preferences.getBoolean(Constants.PREFERENCE_SHOWSONGIMAGE, Constants.DEFAULT_SHOWSONGIMAGE); imagesCache = new LruCache<String, Bitmap>(Constants.IMAGES_CACHE_SIZE); serviceIntent = new Intent(this, MusicService.class); startService(serviceIntent); // Starts the service if it is not running if (preferences.getBoolean(Constants.PREFERENCE_OPENLASTPAGEONSTART, Constants.DEFAULT_OPENLASTPAGEONSTART)) { openPage(preferences.getInt(Constants.PREFERENCE_LASTPAGE, Constants.DEFAULT_LASTPAGE)); } else { openPage(PAGE_BROWSER); } loadSongFromIntent(); layoutPlaybackControls = findViewById(R.id.layoutPlaybackControls); if (preferences.getBoolean(Constants.PREFERENCE_ENABLEGESTURES, Constants.DEFAULT_ENABLEGESTURES)) { final GestureDetectorCompat gestureDetector = new GestureDetectorCompat(this, new PlayerGestureListener()); View layoutTop = findViewById(R.id.layoutTop); layoutTop.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }); if (preferences.getBoolean(Constants.PREFERENCE_SHOWPLAYBACKCONTROLS, Constants.DEFAULT_SHOWPLAYBACKCONTROLS)) { layoutPlaybackControls.setVisibility(View.VISIBLE); } } else { layoutPlaybackControls.setVisibility(View.VISIBLE); } }
From source file:com.andrew.apollo.menu.PlaylistDialog.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(new LinearLayout(this)); action = getIntent().getAction();/*from w w w. j ava 2 s.c o m*/ mRenameId = icicle != null ? icicle.getLong(INTENT_KEY_RENAME) : getIntent().getLongExtra(INTENT_KEY_RENAME, -1); mList = icicle != null ? icicle.getLongArray(INTENT_PLAYLIST_LIST) : getIntent().getLongArrayExtra(INTENT_PLAYLIST_LIST); if (INTENT_RENAME_PLAYLIST.equals(action)) { mOriginalName = nameForId(mRenameId); mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : mOriginalName; } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mDefaultName = icicle != null ? icicle.getString(INTENT_KEY_DEFAULT_NAME) : makePlaylistName(); mOriginalName = mDefaultName; } DisplayMetrics dm = new DisplayMetrics(); dm = getResources().getDisplayMetrics(); mPlaylistDialog = new AlertDialog.Builder(this).create(); mPlaylistDialog.setVolumeControlStream(AudioManager.STREAM_MUSIC); if (action != null && mRenameId >= 0 && mOriginalName != null || mDefaultName != null) { mPlaylist = new EditText(this); mPlaylist.setSingleLine(true); mPlaylist.setText(mDefaultName); mPlaylist.setSelection(mDefaultName.length()); mPlaylist.addTextChangedListener(this); mPlaylistDialog.setIcon(android.R.drawable.ic_dialog_info); String promptformat; String prompt = ""; if (INTENT_RENAME_PLAYLIST.equals(action)) { promptformat = getString(R.string.rename_playlist); prompt = String.format(promptformat, mOriginalName, mDefaultName); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { promptformat = getString(R.string.new_playlist); prompt = String.format(promptformat, mDefaultName); } mPlaylistDialog.setTitle(prompt); mPlaylistDialog.setView(mPlaylist, (int) (8 * dm.density), (int) (8 * dm.density), (int) (8 * dm.density), (int) (4 * dm.density)); if (INTENT_RENAME_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mRenamePlaylistListener); mPlaylistDialog.setOnShowListener(this); } else if (INTENT_CREATE_PLAYLIST.equals(action)) { mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), mCreatePlaylistListener); } mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); mPlaylistDialog.setOnCancelListener(this); mPlaylistDialog.show(); } else { Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show(); finish(); } }
From source file:net.sf.asap.Player.java
public void run() { int config = info.getChannels() == 1 ? AudioFormat.CHANNEL_CONFIGURATION_MONO : AudioFormat.CHANNEL_CONFIGURATION_STEREO; int len = AudioTrack.getMinBufferSize(ASAP.SAMPLE_RATE, config, AudioFormat.ENCODING_PCM_8BIT); if (len < 16384) len = 16384;/* w w w . ja v a2s . c om*/ final byte[] buffer = new byte[len]; audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, ASAP.SAMPLE_RATE, config, AudioFormat.ENCODING_PCM_8BIT, len, AudioTrack.MODE_STREAM); audioTrack.play(); for (;;) { synchronized (this) { if (len < buffer.length || isPaused()) { try { wait(); } catch (InterruptedException ex) { } } if (stop) { audioTrack.stop(); return; } } synchronized (asap) { len = asap.generate(buffer, buffer.length, ASAPSampleFormat.U8); } audioTrack.write(buffer, 0, len); } }
From source file:com.orange.essentials.otb.ui.OtbTermsFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mView = inflater.inflate(R.layout.otb_terms, container, false); LinearLayout llayout = (LinearLayout) mView.findViewById(R.id.otb_terms_layout); TextView headerTv = (TextView) llayout.findViewById(R.id.otb_header_tv_text); headerTv.setText(R.string.otb_home_terms_content); List<Term> terms = TrustBadgeManager.INSTANCE.getTerms(); for (Term term : terms) { View layoutToAdd = null;//from w w w .j ava 2 s . co m if (term.getTermType() == TermType.VIDEO && Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_video, null); TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_video_title); final AutoResizingFrameLayout anchorView = (AutoResizingFrameLayout) layoutToAdd .findViewById(R.id.videoSurfaceContainer); if (mVideoViews == null) { mVideoViews = new ArrayList<>(); } mVideoViews.add(anchorView); SurfaceView videoSurface = (SurfaceView) layoutToAdd.findViewById(R.id.videoSurface); titleTv.setText(term.getTitleId()); SurfaceHolder videoHolder = videoSurface.getHolder(); MediaPlayer player = new MediaPlayer(); if (mPlayers == null) { mPlayers = new ArrayList<>(); } mPlayers.add(player); final VideoControllerView controller = new VideoControllerView(getContext()); VideoCallback videoCallback = new VideoCallback(player, controller, anchorView); videoHolder.addCallback(videoCallback); anchorView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { controller.show(); return false; } }); try { player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setDataSource(getContext(), Uri.parse(getString(term.getContentId()))); player.setOnPreparedListener(videoCallback); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else if (term.getTermType() == TermType.TEXT) {//TermType.TEXT layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_text, null); TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_title); TextView contentTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_content); titleTv.setText(term.getTitleId()); contentTv.setText(Html.fromHtml(getString(term.getContentId()))); contentTv.setMovementMethod(LinkMovementMethod.getInstance()); contentTv.setLinkTextColor(getResources().getColor(R.color.colorAccent)); } if (null != layoutToAdd) { llayout.addView(layoutToAdd); } if (terms.indexOf(term) != terms.size() - 1) { View.inflate(getActivity(), R.layout.otb_separator, llayout); } } return mView; }
From source file:com.wipro.sa349342.wmar.AbstractArchitectCamActivity.java
/** Called when the activity is first created. */ @SuppressLint("NewApi") @Override/*from w w w .j a v a 2 s . c o m*/ public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* pressing volume up/down should cause music volume changes */ this.setVolumeControlStream(AudioManager.STREAM_MUSIC); /* set samples content view */ this.setContentView(this.getContentViewId()); this.setTitle(this.getActivityTitle()); View mapFrag = findViewById(R.id.map); if (this.isMapPanelRequired()) { mapFrag.setVisibility(View.VISIBLE); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(map); mapFragment.getMapAsync(AbstractArchitectCamActivity.this); } else { mapFrag.setVisibility(View.GONE); } /* * this enables remote debugging of a WebView on Android 4.4+ when debugging = true in AndroidManifest.xml * If you get a compile time error here, ensure to have SDK 19+ used in your ADT/Eclipse. * You may even delete this block in case you don't need remote debugging or don't have an Android 4.4+ device in place. * Details: https://developers.google.com/chrome-developer-tools/docs/remote-debugging */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) { WebView.setWebContentsDebuggingEnabled(true); } } /* set AR-view for life-cycle notifications etc. */ this.architectView = (ArchitectView) this.findViewById(this.getArchitectViewId()); /* pass SDK key if you have one, this one is only valid for this package identifier and must not be used somewhere else */ final StartupConfiguration config = new StartupConfiguration(this.getWikitudeSDKLicenseKey(), this.getFeatures(), this.getCameraPosition()); try { /* first mandatory life-cycle notification */ this.architectView.onCreate(config); } catch (RuntimeException rex) { this.architectView = null; Toast.makeText(getApplicationContext(), "can't create Architect View", Toast.LENGTH_SHORT).show(); Log.e(this.getClass().getName(), "Exception in ArchitectView.onCreate()", rex); } // set accuracy listener if implemented, you may e.g. show calibration prompt for compass using this listener this.sensorAccuracyListener = this.getSensorAccuracyListener(); // set urlListener, any calls made in JS like "document.location = 'architectsdk://foo?bar=123'" is forwarded to this listener, use this to interact between JS and native Android activity/fragment this.urlListener = this.getUrlListener(); // register valid urlListener in architectView, ensure this is set before content is loaded to not miss any event if (this.urlListener != null && this.architectView != null) { this.architectView.registerUrlListener(this.getUrlListener()); } if (hasGeo()) { // listener passed over to locationProvider, any location update is handled here this.locationListener = new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } @Override public void onLocationChanged(final Location location) { // forward location updates fired by LocationProvider to architectView, you can set lat/lon from any location-strategy if (location != null) { // sore last location as member, in case it is needed somewhere (in e.g. your adjusted project) AbstractArchitectCamActivity.this.lastKnownLocaton = location; if (AbstractArchitectCamActivity.this.architectView != null) { // check if location has altitude at certain accuracy level & call right architect method (the one with altitude information) if (location.hasAltitude() && location.hasAccuracy() && location.getAccuracy() < 7) { AbstractArchitectCamActivity.this.architectView.setLocation(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy()); } else { AbstractArchitectCamActivity.this.architectView.setLocation(location.getLatitude(), location.getLongitude(), location.hasAccuracy() ? location.getAccuracy() : 1000); } } // currentLocationMarker(location); } } }; // locationProvider used to fetch user position this.locationProvider = getLocationProvider(this.locationListener); } else { this.locationProvider = null; this.locationListener = null; } }
From source file:com.ksharkapps.musicnow.ui.activities.SearchActivity.java
/** * {@inheritDoc}/* w w w.ja v a 2s. c o m*/ */ @SuppressWarnings("deprecation") @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); actionBar = getSupportActionBar(); // Fade it in overridePendingTransition(R.anim.swipeback_stack_right_in, R.anim.swipeback_stack_to_back); // Control the media volume setVolumeControlStream(AudioManager.STREAM_MUSIC); // Bind Apollo's service mToken = MusicUtils.bindToService(this, this); // Theme the action bar final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); // Set the layout setContentView(R.layout.grid_base); // Give the background a little UI final FrameLayout background = (FrameLayout) findViewById(R.id.grid_base_container); background.setBackgroundDrawable(getResources().getDrawable(R.drawable.pager_background)); // Get the query final String query = getIntent().getStringExtra(SearchManager.QUERY); mFilterString = !TextUtils.isEmpty(query) ? query : null; // Action bar subtitle actionBar.setSubtitle("\"" + mFilterString + "\""); // Initialize the adapter mAdapter = new SearchAdapter(this); // Set the prefix mAdapter.setPrefix(mFilterString); // Initialze the list mGridView = (GridView) findViewById(R.id.grid_base); // Bind the data mGridView.setAdapter(mAdapter); // Recycle the data mGridView.setRecyclerListener(new RecycleHolder()); // Seepd up scrolling mGridView.setOnScrollListener(this); mGridView.setOnItemClickListener(this); if (ApolloUtils.isLandscape(this)) { mGridView.setNumColumns(TWO); } else { mGridView.setNumColumns(ONE); } // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); }
From source file:com.perm.DoomPlay.PlayingService.java
@Override public void onCreate() { super.onCreate(); isLoadingTrack = false;/*from w w w . ja v a 2 s. c o m*/ isShuffle = false; isPlaying = true; isLoop = false; afListener = new AFListener(); audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.requestAudioFocus(afListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); ComponentName componentName = new ComponentName(this, MediaButtonReceiver.class); audioManager.registerMediaButtonEventReceiver(componentName); ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).listen(callListener, CallListener.LISTEN_CALL_STATE); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); serviceAlive = true; bassPlayer = new BassPlayer(); bassPlayer.setOnCompletetion(this); }