Example usage for android.media.audiofx AudioEffect EXTRA_PACKAGE_NAME

List of usage examples for android.media.audiofx AudioEffect EXTRA_PACKAGE_NAME

Introduction

In this page you can find the example usage for android.media.audiofx AudioEffect EXTRA_PACKAGE_NAME.

Prototype

String EXTRA_PACKAGE_NAME

To view the source code for android.media.audiofx AudioEffect EXTRA_PACKAGE_NAME.

Click Source Link

Document

Contains the package name of the calling application.

Usage

From source file:com.koma.music.service.MusicService.java

/**
 * {@inheritDoc}//from  ww w.  j  a  va2 s. c  o  m
 */
@Override
public void onDestroy() {
    LogUtils.d(TAG, "Destroying service");
    if (!mReadGranted) {
        return;
    }
    super.onDestroy();
    // Remove any sound effects
    final Intent audioEffectsIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(audioEffectsIntent);

    // remove any pending alarms
    mAlarmManager.cancel(mShutdownIntent);

    // Remove any callbacks from the handler
    mPlayerHandler.removeCallbacksAndMessages(null);
    // quit the thread so that anything that gets posted won't run
    mHandlerThread.quitSafely();

    // Release the player
    mPlayer.release();
    mPlayer = null;

    // Remove the audio focus listener and lock screen controls
    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    mSession.release();

    // remove the media store observer
    getContentResolver().unregisterContentObserver(mMediaObserver);

    // Close the cursor
    closeCursor();

    // Unregister the mount listener
    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }

    // deinitialize shake detector
    stopShakeDetector(true);
}

From source file:github.popeen.dsub.service.DownloadService.java

@Override
public void onDestroy() {
    super.onDestroy();
    instance = null;//from w w w .ja v  a 2  s.co m

    if (currentPlaying != null)
        currentPlaying.setPlaying(false);
    if (sleepTimer != null) {
        sleepTimer.cancel();
        sleepTimer.purge();
    }
    lifecycleSupport.onDestroy();

    try {
        Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
        i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, audioSessionId);
        i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
        sendBroadcast(i);
    } catch (Throwable e) {
        // Froyo or lower
    }

    mediaPlayer.release();
    if (nextMediaPlayer != null) {
        nextMediaPlayer.release();
    }
    mediaPlayerLooper.quit();
    shufflePlayBuffer.shutdown();
    effectsController.release();
    if (mRemoteControl != null) {
        mRemoteControl.unregister(this);
        mRemoteControl = null;
    }

    if (bufferTask != null) {
        bufferTask.cancel();
        bufferTask = null;
    }
    if (nextPlayingTask != null) {
        nextPlayingTask.cancel();
        nextPlayingTask = null;
    }
    if (remoteController != null) {
        remoteController.stop();
        remoteController.shutdown();
    }
    if (proxy != null) {
        proxy.stop();
        proxy = null;
    }
    if (audioNoisyReceiver != null) {
        unregisterReceiver(audioNoisyReceiver);
    }
    mediaRouter.destroy();
    Notifications.hidePlayingNotification(this, this, handler);
    Notifications.hideDownloadingNotification(this, this, handler);
}

From source file:com.devalladolid.musictoday.MusicService.java

@Override
public void onDestroy() {
    if (D)/*from  w  w  w.  j a v a 2s.  c  o m*/
        Log.d(TAG, "Destroying service");
    super.onDestroy();
    // Remove any sound effects
    final Intent audioEffectsIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(audioEffectsIntent);

    mAlarmManager.cancel(mShutdownIntent);

    mPlayerHandler.removeCallbacksAndMessages(null);

    if (TimberUtils.isJellyBeanMR2())
        mHandlerThread.quitSafely();
    else
        mHandlerThread.quit();

    mPlayer.release();
    mPlayer = null;

    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        mSession.release();

    getContentResolver().unregisterContentObserver(mMediaStoreObserver);

    closeCursor();

    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }

    mWakeLock.release();
}

From source file:com.rks.musicx.ui.activities.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == OVERLAY_REQ) {
        if (Build.VERSION.SDK_INT >= M) {
            if (Settings.canDrawOverlays(this)) {
                Log.d("MainActivity", "Granted");
            } else {
                Extras.getInstance().setWidgetTrack(true);
                Log.d("MainActivity", "Denied or Grant permission Manually");
            }/* w w w.  j  a  va2  s .  c o m*/
        }
    }
    if (requestCode == WRITESETTINGS) {
        if (Build.VERSION.SDK_INT >= M) {
            if (!Settings.System.canWrite(this)) {
                Log.d("MainActivity", "Granted");
            } else {
                Extras.getInstance().setSettings(true);
                Log.d("MainActivity", "Denied or Grant permission Manually");
            }
        }
    }
    if (requestCode == EQ) {
        Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
        if (intent.getAction() != null && Helper.isActivityPresent(MainActivity.this, intent)) {
            if (musicXService == null) {
                return;
            }
            intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, musicXService.audioSession());
            intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, this.getPackageName());
            intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
            sendBroadcast(intent);
        } else {
            Log.d("MainActivity", "Error");
        }
    }
    if (requestCode == NAV && resultCode == RESULT_OK) {
        intent = data;
    }
}

From source file:com.bluros.music.MusicService.java

@Override
public void onDestroy() {
    if (D)/*from w w w .  ja v a2s.  c  om*/
        Log.d(TAG, "Destroying service");
    super.onDestroy();
    // Remove any sound effects
    final Intent audioEffectsIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(audioEffectsIntent);

    mAlarmManager.cancel(mShutdownIntent);

    mPlayerHandler.removeCallbacksAndMessages(null);

    if (MusicUtils.isJellyBeanMR2())
        mHandlerThread.quitSafely();
    else
        mHandlerThread.quit();

    mPlayer.release();
    mPlayer = null;

    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        mSession.release();

    getContentResolver().unregisterContentObserver(mMediaStoreObserver);

    closeCursor();

    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }

    stopShakeDetector(true);

    mWakeLock.release();
}

From source file:com.av.remusic.service.MediaService.java

@Override
public void onDestroy() {
    if (D)/*from  w ww .  ja v a 2  s  .  co m*/
        Log.d(TAG, "Destroying service");
    super.onDestroy();
    // Remove any sound effects
    final Intent audioEffectsIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(audioEffectsIntent);

    cancelNotification();

    mAlarmManager.cancel(mShutdownIntent);

    mPlayerHandler.removeCallbacksAndMessages(null);

    if (CommonUtils.isJellyBeanMR2())
        mHandlerThread.quitSafely();
    else
        mHandlerThread.quit();

    mPlayer.release();
    mPlayer = null;

    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        mSession.release();

    getContentResolver().unregisterContentObserver(mMediaStoreObserver);

    closeCursor();

    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }

    mWakeLock.release();
}

From source file:com.andrew.apolloMod.service.ApolloService.java

@Override
public void onDestroy() {
    // Check that we're not being destroyed while something is still
    // playing.//from   w  w  w  .  j a  va  2s.  c  o  m
    if (mIsSupposedToBePlaying) {
        Log.e(LOGTAG, "Service being destroyed while still playing.");
    }
    // release all MediaPlayer resources, including the native player and
    // wakelocks
    Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(i);
    mPlayer.release();
    mPlayer = null;

    mAudioManager.abandonAudioFocus(mAudioFocusListener);

    if (Constants.isApi14Supported()) {
        mAudioManager.unregisterRemoteControlClient(mRemoteControlClient);
    }

    // make sure there aren't any other messages coming
    mDelayedStopHandler.removeCallbacksAndMessages(null);
    mMediaplayerHandler.removeCallbacksAndMessages(null);

    if (mCursor != null) {
        mCursor.close();
        mCursor = null;
    }
    updateAlbumBitmap();

    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }
    mWakeLock.release();
    super.onDestroy();
}

From source file:singh.amandeep.musicplayer.MusicService.java

/**
 * {@inheritDoc}/* w  w  w  .  ja va 2s .  c o  m*/
 */
@Override
public void onDestroy() {
    if (D)
        Log.d(TAG, "Destroying service");
    super.onDestroy();
    // Remove any sound effects
    final Intent audioEffectsIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(audioEffectsIntent);

    // remove any pending alarms
    mAlarmManager.cancel(mShutdownIntent);

    // Remove any callbacks from the handler
    mPlayerHandler.removeCallbacksAndMessages(null);
    // quit the thread so that anything that gets posted won't run
    mHandlerThread.quitSafely();

    // Release the player
    mPlayer.release();
    mPlayer = null;

    // Remove the audio focus listener and lock screen controls
    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    mSession.release();

    // remove the media store observer
    getContentResolver().unregisterContentObserver(mMediaStoreObserver);

    // Close the cursor
    closeCursor();

    // Unregister the mount listener
    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }

    // Release the wake lock
    mWakeLock.release();
}

From source file:com.andrew.apollo.MusicPlaybackService.java

/**
 * {@inheritDoc}/*from  w  w w . ja v  a2s. c  o m*/
 */
@Override
public void onDestroy() {
    if (D)
        LOG.info("Destroying service");
    super.onDestroy();

    // Tell any sound effect processors (e.g. equalizers) that we're leaving
    try {
        final Intent audioEffectsIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
        audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
        audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
        sendBroadcast(audioEffectsIntent);
    } catch (Throwable ignored) {
    }

    // remove any pending alarms
    // note: mShutdownIntent could be null because during creation
    // internally PendingIntent.getService is eating (and ignoring)
    // a possible RemoteException
    if (mAlarmManager != null && mShutdownIntent != null) {
        mAlarmManager.cancel(mShutdownIntent);
    }

    // Remove all pending messages before kill the player
    if (mPlayerHandler != null) {
        mPlayerHandler.removeCallbacksAndMessages(null);
    }

    // Release the player
    if (mPlayer != null) {
        mPlayer.release();
        mPlayer = null;
    }

    // Release simple player
    if (mSimplePlayer != null) {
        mSimplePlayer.release();
        mSimplePlayer = null;
    }

    // Remove the audio focus listener and lock screen controls
    if (mAudioManager != null) {
        mAudioManager.abandonAudioFocus(mAudioFocusListener);
        mAudioManager.unregisterRemoteControlClient(mRemoteControlClient);
    }

    // Remove any callbacks from the handler
    if (mPlayerHandler != null) {
        mPlayerHandler.removeCallbacksAndMessages(null);
        mPlayerHandler.getLooper().quit();
    }

    // Close the cursor
    closeCursor();

    // Unregister the mount listener
    try {
        unregisterReceiver(mIntentReceiver);
    } catch (Throwable ignored) {
    }

    if (mUnmountReceiver != null) {
        try {
            unregisterReceiver(mUnmountReceiver);
        } catch (Throwable ignored) {
        }
        mUnmountReceiver = null;
    }

    // Release the wake lock
    if (mWakeLock != null) {
        try {
            mWakeLock.release();
        } catch (RuntimeException ignored) {
            // might be underlocked and otherwise causing a crash on shutdown
        }
    }
}

From source file:com.cyanogenmod.eleven.MusicPlaybackService.java

/**
 * {@inheritDoc}/*from ww w  . j  av  a  2  s .  co  m*/
 */
@Override
public void onDestroy() {
    if (D)
        Log.d(TAG, "Destroying service");
    super.onDestroy();
    // Remove any sound effects
    final Intent audioEffectsIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(audioEffectsIntent);

    // remove any pending alarms
    mAlarmManager.cancel(mShutdownIntent);

    // Remove any callbacks from the handler
    mPlayerHandler.removeCallbacksAndMessages(null);
    // quit the thread so that anything that gets posted won't run
    mHandlerThread.quitSafely();

    // Release the player
    mPlayer.release();
    mPlayer = null;

    // Remove the audio focus listener and lock screen controls
    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    mSession.release();

    // remove the media store observer
    getContentResolver().unregisterContentObserver(mMediaStoreObserver);

    // Close the cursor
    closeCursor();

    // Unregister the mount listener
    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }

    // deinitialize shake detector
    stopShakeDetector(true);
}