List of usage examples for android.content Context AUDIO_SERVICE
String AUDIO_SERVICE
To view the source code for android.content Context AUDIO_SERVICE.
Click Source Link
From source file:com.intel.xdk.player.Player.java
public void playSoundById(final int id) { AudioManager mgr = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE); int streamVolume = mgr.getStreamVolume(AudioManager.STREAM_MUSIC); int streamMaximum = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC); float volume = (float) streamVolume / (float) streamMaximum; int playingSound = soundPool.play(id, volume, volume, 0, 0, 1f); //should inject playingSound so it can be stopped/paused/resumed? }
From source file:org.drrickorang.loopback.LoopbackActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set the layout for this activity. You can find it View view = getLayoutInflater().inflate(R.layout.main_activity, null); setContentView(view);//from w ww .j av a2s.c o m mTextInfo = (TextView) findViewById(R.id.textInfo); mBarMasterLevel = (SeekBar) findViewById(R.id.BarMasterLevel); AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); int maxVolume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC); mBarMasterLevel.setMax(maxVolume); mBarMasterLevel.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); am.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0); refreshState(); log("Changed stream volume to: " + progress); } }); mWavePlotView = (WavePlotView) findViewById(R.id.viewWavePlot); mTextViewCurrentLevel = (TextView) findViewById(R.id.textViewCurrentLevel); mTextViewCurrentLevel.setTextSize(15); mTextViewEstimatedLatency = (TextView) findViewById(R.id.textViewEstimatedLatency); refreshState(); applyIntent(getIntent()); }
From source file:de.spiritcroc.modular_remote.MainActivity.java
@Override protected void onResume() { super.onResume(); appWidgetHost.startListening();// w ww . j a v a 2 s .c om tcpConnectionManager.refreshConnections(); viewPager.addOnPageChangeListener(this); onPageSelected(viewPager.getCurrentItem()); int tmp = Util.getPreferenceInt(sharedPreferences, Preferences.OFFSCREEN_PAGE_LIMIT, 2); if (tmp < 0) { neverDestroyPages = true; viewPager.setOffscreenPageLimit(pages.size()); } else { neverDestroyPages = false; viewPager.setOffscreenPageLimit(tmp); } fullscreen = sharedPreferences.getBoolean(Preferences.FULLSCREEN, false); hideNavigationBar = sharedPreferences.getBoolean(Preferences.HIDE_NAVIGATION_BAR, false); hideActionBar = sharedPreferences.getBoolean(Preferences.HIDE_ACTION_BAR, false); int pagerTabStripVisibility = sharedPreferences.getBoolean(Preferences.HIDE_PAGER_TAB_STRIP, false) ? View.GONE : View.VISIBLE; if (pagerTabStrip.getVisibility() != pagerTabStripVisibility) { pagerTabStrip.setVisibility(pagerTabStripVisibility); } String ringerMode = sharedPreferences.getString(Preferences.CHANGE_RINGER_MODE, getString(R.string.pref_ringer_mode_keep_value)); AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); previousRingerMode = audioManager.getRingerMode(); if (getString(R.string.pref_ringer_mode_mute_value).equals(ringerMode)) { audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); changedRingerMode = true; } else if (getString(R.string.pref_ringer_mode_vibrate_value).equals(ringerMode)) { audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); changedRingerMode = true; } else if (getString(R.string.pref_ringer_mode_vibrate_if_not_muted_value).equals(ringerMode) && previousRingerMode != AudioManager.RINGER_MODE_SILENT) { audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); changedRingerMode = true; } if (forceOrientation == FORCE_ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (forceOrientation == FORCE_ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { String orientation = sharedPreferences.getString(Preferences.ORIENTATION, Preferences.ORIENTATION_SHARE_LAYOUT); if (Preferences.ORIENTATION_PORTRAIT_ONLY.equals(orientation)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (Preferences.ORIENTATION_LANDSCAPE_ONLY.equals(orientation)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); } } resizeContent(); setLockedModeVisibilities(); }
From source file:com.z3r0byte.magistify.Services.BackgroundService.java
private void autoSilent() { Appointment[] appointments = calendarDB.getSilentAppointments(getMargin()); if (doSilent(appointments)) { setSilenced(true);/*from ww w.j a v a 2s. c o m*/ AudioManager audiomanager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audiomanager == null) return; if (!isSilencedByApp()) configUtil.setInteger("previous_silent_state", audiomanager.getRingerMode()); if (audiomanager.getRingerMode() != AudioManager.RINGER_MODE_SILENT) { audiomanager.setRingerMode(AudioManager.RINGER_MODE_SILENT); } } else { if (isSilencedByApp()) { AudioManager audiomanager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audiomanager == null) return; if (configUtil.getBoolean("reverse_silent_state")) { audiomanager.setRingerMode(configUtil.getInteger("previous_silent_state")); } else { audiomanager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); } setSilenced(false); } } }
From source file:com.lybeat.lilyplayer.widget.media.IjkVideoView.java
public void stopPlayback() { if (mMediaPlayer != null) { mMediaPlayer.stop();/*from ww w . j av a 2 s .c o m*/ mMediaPlayer.release(); mMediaPlayer = null; if (mHudViewHolder != null) mHudViewHolder.setMediaPlayer(null); mCurrentState = STATE_IDLE; mTargetState = STATE_IDLE; AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE); am.abandonAudioFocus(null); } }
From source file:com.av.remusic.service.MediaService.java
@Override public void onCreate() { if (D)// w w w . java2s.c o m Log.d(TAG, "Creating service"); super.onCreate(); mGetUrlThread.start(); mLrcThread.start(); mProxy = new MediaPlayerProxy(this); mProxy.init(); mProxy.start(); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // gets a pointer to the playback state store mPlaybackStateStore = MusicPlaybackState.getInstance(this); mSongPlayCount = SongPlayCount.getInstance(this); mRecentStore = RecentStore.getInstance(this); mHandlerThread = new HandlerThread("MusicPlayerHandler", android.os.Process.THREAD_PRIORITY_BACKGROUND); mHandlerThread.start(); mPlayerHandler = new MusicPlayerHandler(this, mHandlerThread.getLooper()); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mMediaButtonReceiverComponent = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()); mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setUpMediaSession(); } mPreferences = getSharedPreferences("Service", 0); mCardId = getCardId(); registerExternalStorageListener(); mPlayer = new MultiPlayer(this); mPlayer.setHandler(mPlayerHandler); // Initialize the intent filter and each action final IntentFilter filter = new IntentFilter(); filter.addAction(SERVICECMD); filter.addAction(TOGGLEPAUSE_ACTION); filter.addAction(PAUSE_ACTION); filter.addAction(STOP_ACTION); filter.addAction(NEXT_ACTION); filter.addAction(PREVIOUS_ACTION); filter.addAction(PREVIOUS_FORCE_ACTION); filter.addAction(REPEAT_ACTION); filter.addAction(SHUFFLE_ACTION); filter.addAction(TRY_GET_TRACKINFO); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(LOCK_SCREEN); filter.addAction(SEND_PROGRESS); filter.addAction(SETQUEUE); // Attach the broadcast listener registerReceiver(mIntentReceiver, filter); mMediaStoreObserver = new MediaStoreObserver(mPlayerHandler); getContentResolver().registerContentObserver(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, true, mMediaStoreObserver); getContentResolver().registerContentObserver(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mMediaStoreObserver); // Initialize the wake lock final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName()); mWakeLock.setReferenceCounted(false); final Intent shutdownIntent = new Intent(this, MediaService.class); shutdownIntent.setAction(SHUTDOWN); mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mShutdownIntent = PendingIntent.getService(this, 0, shutdownIntent, 0); scheduleDelayedShutdown(); reloadQueueAfterPermissionCheck(); notifyChange(QUEUE_CHANGED); notifyChange(META_CHANGED); }
From source file:usbong.android.likha_collection_1.UsbongDecisionTreeEngineActivity.java
public void init() { //if return is null, then currScreen=0 // currScreen=Integer.parseInt(getIntent().getStringExtra("currScreen")); //modified by JPT, May 25, 2015 if (getIntent().getStringExtra("currScreen") != null) { currScreen = Integer.parseInt(getIntent().getStringExtra("currScreen")); }/*w ww.j a v a2 s .c o m*/ //updated by Mike, 20160608 /* currLanguageBeingUsed=UsbongUtils.LANGUAGE_ENGLISH; UsbongUtils.setCurrLanguage("English"); //added by Mike, 22 Sept. 2015 */ //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example //; last accessed: 9 June 2015 //answer by Elenasys //added by Mike, 9 June 2015 SharedPreferences prefs = getSharedPreferences(UsbongConstants.MY_SAVED_LANGUAGE_SETTING, MODE_PRIVATE); if (prefs != null) { //@todo: remove this id thing, immediately use the String; otherwise it'll be cumbersome to keep on adding language ids currLanguageBeingUsed = prefs.getInt("preferredLanguage", UsbongUtils.getLanguageID(UsbongUtils.getCurrLanguage())); //default is Filipino /* //commented out by Mike, 20160608 * //default language will be set based on the default language set in the .xml of the .utree file * UsbongUtils.setDefaultLanguage(UsbongUtils.getLanguageBasedOnID(currLanguageBeingUsed)); */ UsbongUtils.setCurrLanguage(UsbongUtils.getLanguageBasedOnID(currLanguageBeingUsed));//prefs.getInt("preferredLanguage", 0))); //updated by Mike, 20160612 } else { //default.. currLanguageBeingUsed = UsbongUtils.getLanguageID(UsbongUtils.getCurrLanguage()); //UsbongUtils.setCurrLanguage(UsbongUtils.getLanguageBasedOnID(currLanguageBeingUsed)); //updated by Mike, 20160612 } /* //commented out by Mike, 20160618 * //why? the index numbers used by currSelectedItemForSetLanguage does not always match with currLanguageBeingUsed * //added by Mike, 20160608 * currSelectedItemForSetLanguage = currLanguageBeingUsed; */ //================================================================== //text-to-speech stuff /*//comment out, not needed in DAHON, * commented out by Mike, 20160613 Intent checkIntent = new Intent(); checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); startActivityForResult(checkIntent, UsbongUtils.MY_DATA_CHECK_CODE); */ mTts = new TextToSpeech(this, this); mTts.setLanguage(new Locale("en", "US"));//default //================================================================== myMediaPlayer = new MediaPlayer(); myMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); //added by Mike, 22 July 2015 myMediaPlayer.setVolume(1.0f, 1.0f); //added by Mike, 25 Sept. 2015 myBGMediaPlayer = new MediaPlayer(); myBGMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); myBGMediaPlayer.setVolume(0.5f, 0.5f); //added by Mike, 22 July 2015 AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); am.setStreamVolume(AudioManager.STREAM_MUSIC, am.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0); usbongNodeContainer = new Vector<String>(); classificationContainer = new Vector<String>(); radioButtonsContainer = new Vector<String>(); usbongAnswerContainer = new Vector<String>(); checkBoxesContainer = new Vector<String>(); decisionTrackerContainer = new Vector<String>(); usedBackButton = false; currAnswer = ""; try { //commented out by Mike, 4 Oct. 2015 UsbongUtils.createUsbongFileStructure(); //added by Mike, 20160417 UsbongUtils.initUsbongConfigFile(); //create the usbong_demo_tree and store it in sdcard/usbong/usbong_trees // UsbongUtils.storeAssetsFileIntoSDCard(this,"usbong_demo_tree.xml"); // UsbongUtils.storeAssetsFileIntoSDCard(this,UsbongUtils.DEFAULT_UTREE_TO_LOAD+".utree"); //edited by Mike, 20161111 UsbongUtils.storeAssetsFileIntoSDCard(this, "pagtsing.utree"); UsbongUtils.storeAssetsFileIntoSDCard(this, "gamugamo.utree"); UsbongUtils.storeAssetsFileIntoSDCard(this, "juant.utree"); UsbongUtils.storeAssetsFileIntoSDCard(this, "pagtsing_icon.png"); UsbongUtils.storeAssetsFileIntoSDCard(this, "gamugamo_icon.png"); UsbongUtils.storeAssetsFileIntoSDCard(this, "juant_icon.png"); } catch (IOException ioe) { ioe.printStackTrace(); } //Reference: http://stackoverflow.com/questions/2793004/java-lista-addalllistb-fires-nullpointerexception //Last accessed: 14 March 2012 attachmentFilePaths = new ArrayList<String>(); // attachmentFilePaths.clear(); // System.out.println(">>>>>>>>> attachmentFilePaths.clear!"); currAudioRecorder = null; myQRCodeContent = ""; hasReturnedFromAnotherActivity = false; //camera, paint, email, etc //added by Mike, March 4, 2013 usbongAnswerContainerCounter = 0; /* ArrayList<String> skuList = new ArrayList<String> (); skuList.add(UsbongConstants.ALL_LOCAL_LANGUAGES_PRODUCT_ID); skuList.add(UsbongConstants.ALL_FOREIGN_LANGUAGES_PRODUCT_ID); Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); */ new AsyncTask<String, Integer, Boolean>() { @Override protected void onPostExecute(Boolean result) { //added by Mike, 20160421 //init purchase languages list purchaseLanguagesListDialog = new AlertDialog.Builder(getInstance()); myPurchaseLanguageBundleListAdapter = new PurchaseLanguageBundleListAdapter(getInstance(), UsbongUtils.getInAppOwnedItems(), UsbongUtils.getInAppMService()); purchaseLanguagesListDialog.setTitle("Purchase"); purchaseLanguagesListDialog.setSingleChoiceItems(myPurchaseLanguageBundleListAdapter, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Log.i("Selected Item : ", (String) myPurchaseLanguageBundleListAdapter.getItem(which)); dialog.dismiss(); //edited by Mike, 20160508 // purchaseLanguagesListDialogInterface = dialog; } }); purchaseLanguagesListDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); } @Override protected Boolean doInBackground(String... params) { try { UsbongUtils.initInAppBillingService(getInstance()); UsbongUtils.initInAppBillingService(getInstance()); //need to call this twice to get the updated languageBundleList } catch (Exception e) { e.printStackTrace(); } return true; } }.execute(); //reference: Labeeb P's answer from stackoverflow; //http://stackoverflow.com/questions/4275797/view-setpadding-accepts-only-in-px-is-there-anyway-to-setpadding-in-dp; //last accessed: 23 May 2013 final float scale = getResources().getDisplayMetrics().density; padding_in_px = (int) (padding_in_dp * scale + 0.5f); //added by Mike, 25 June 2013 UsbongUtils.setDebugMode(UsbongUtils.isInDebugMode()); //added by Mike, 25 Feb. 2014 // UsbongUtils.setStoreOutput(UsbongUtils.checkIfStoreOutput()); UsbongUtils.setStoreOutput(false); //don't store output, added by Mike, 27 Sept. 2015 myUsbongScreenProcessor = new UsbongScreenProcessor(UsbongDecisionTreeEngineActivity.getInstance()); myUsbongVariableMemory = new HashMap<String, String>(); //added by Mike, March 26, 2014 try { Log.d(">>>>", "" + UsbongUtils.STORE_OUTPUT); if (UsbongUtils.STORE_OUTPUT) { //added by Mike, 27 Sept. 2015 UsbongUtils.createNewOutputFolderStructure(); } } catch (Exception e) { e.printStackTrace(); } /*//commented out by Mike, 20161110 //added by Mike, 30 April 2015 isInTreeLoader=false; myTree = UsbongUtils.DEFAULT_UTREE_TO_LOAD; //edited by Mike, 20160418 UsbongUtils.clearTempFolder(); */ initTreeLoader(); }
From source file:com.lybeat.lilyplayer.widget.media.IjkVideoView.java
@TargetApi(Build.VERSION_CODES.M) private void openVideo() { if (mUri == null || mSurfaceHolder == null) { // not ready for playback just yet, will try again later return;/*from www.jav a 2 s. c om*/ } // we shouldn't clear the target state, because somebody might have // called start() previously release(false); AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE); am.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); try { mMediaPlayer = createPlayer(mSettings.getPlayer()); // TODO: create SubtitleController in MediaPlayer, but we need // a context for the subtitle renderers final Context context = getContext(); // REMOVED: SubtitleController // REMOVED: mAudioSession mMediaPlayer.setOnPreparedListener(mPreparedListener); mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener); mMediaPlayer.setOnCompletionListener(mCompletionListener); mMediaPlayer.setOnErrorListener(mErrorListener); mMediaPlayer.setOnInfoListener(mInfoListener); mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener); mCurrentBufferPercentage = 0; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mMediaPlayer.setDataSource(mAppContext, mUri, mHeaders); } else { mMediaPlayer.setDataSource(mUri.toString()); } bindSurfaceHolder(mMediaPlayer, mSurfaceHolder); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setScreenOnWhilePlaying(true); mMediaPlayer.prepareAsync(); if (mHudViewHolder != null) mHudViewHolder.setMediaPlayer(mMediaPlayer); // REMOVED: mPendingSubtitleTracks // we don't set the target state here either, but preserve the // target state that was there before. mCurrentState = STATE_PREPARING; attachMediaController(); } catch (IOException ex) { Log.w(TAG, "Unable to open content: " + mUri, ex); mCurrentState = STATE_ERROR; mTargetState = STATE_ERROR; mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0); return; } catch (IllegalArgumentException ex) { Log.w(TAG, "Unable to open content: " + mUri, ex); mCurrentState = STATE_ERROR; mTargetState = STATE_ERROR; mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0); return; } finally { // REMOVED: mPendingSubtitleTracks.clear(); } }
From source file:org.zoumbox.mh_dla_notifier.Receiver.java
protected Pair<Boolean, Boolean> soundAndVibrate(Context context, PreferencesHolder preferences) { switch (preferences.silentNotification) { case ALWAYS: { // Toujours silencieux (pas de son, pas de vibration) Pair<Boolean, Boolean> result = Pair.of(false, false); return result; }//from w w w . j ava 2 s . c o m case NEVER: { // Jamais silencieux (son + vibration) Pair<Boolean, Boolean> result = Pair.of(true, true); return result; } case BY_NIGHT: { // Ni son, ni vibration entre 23h et 7h Calendar now = Calendar.getInstance(); int hour = now.get(Calendar.HOUR_OF_DAY); boolean soundAndVibrate = hour >= 7 && hour < 23; Pair<Boolean, Boolean> result = Pair.of(soundAndVibrate, soundAndVibrate); return result; } case WHEN_SILENT: { // Dpend du systme AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); int ringerMode = am.getRingerMode(); Pair<Boolean, Boolean> result = Pair.of(ringerMode == AudioManager.RINGER_MODE_NORMAL, // son ringerMode == AudioManager.RINGER_MODE_NORMAL || ringerMode == AudioManager.RINGER_MODE_VIBRATE // vibration ); return result; } default: Log.w(TAG, "Unexpected mode : " + preferences.silentNotification); throw new IllegalStateException("Unexpected mode : " + preferences.silentNotification); } }
From source file:com.andrew.apolloMod.service.ApolloService.java
@SuppressLint({ "WorldWriteableFiles", "WorldReadableFiles" }) @Override//from w w w .j a v a 2s. c o m public void onCreate() { super.onCreate(); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); ComponentName rec = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()); mAudioManager.registerMediaButtonEventReceiver(rec); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(rec); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (Constants.isApi14Supported()) { mRemoteControlClient = new RemoteControlClient(mediaPendingIntent); mAudioManager.registerRemoteControlClient(mRemoteControlClient); int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP; mRemoteControlClient.setTransportControlFlags(flags); } mPreferences = getSharedPreferences(APOLLO_PREFERENCES, MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE); mCardId = MusicUtils.getCardId(this); registerExternalStorageListener(); // Needs to be done in this thread, since otherwise // ApplicationContext.getPowerManager() crashes. mPlayer = new MultiPlayer(); mPlayer.setHandler(mMediaplayerHandler); reloadQueue(); notifyChange(QUEUE_CHANGED); notifyChange(META_CHANGED); IntentFilter commandFilter = new IntentFilter(); commandFilter.addAction(SERVICECMD); commandFilter.addAction(TOGGLEPAUSE_ACTION); commandFilter.addAction(PAUSE_ACTION); commandFilter.addAction(NEXT_ACTION); commandFilter.addAction(PREVIOUS_ACTION); commandFilter.addAction(CYCLEREPEAT_ACTION); commandFilter.addAction(TOGGLESHUFFLE_ACTION); registerReceiver(mIntentReceiver, commandFilter); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName()); mWakeLock.setReferenceCounted(false); // If the service was idle, but got killed before it stopped itself, the // system will relaunch it. Make sure it gets stopped again in that // case. Message msg = mDelayedStopHandler.obtainMessage(); mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY); }