Example usage for android.content Context AUDIO_SERVICE

List of usage examples for android.content Context AUDIO_SERVICE

Introduction

In this page you can find the example usage for android.content Context AUDIO_SERVICE.

Prototype

String AUDIO_SERVICE

To view the source code for android.content Context AUDIO_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.media.AudioManager for handling management of volume, ringer modes and audio routing.

Usage

From source file:com.air.mobilebrowser.BrowserActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ttsPlayer = new TTSPlayer(this);

    // Allow for out-of-band additions to thread queue (mainly for cleanup)
    mHandler = new Handler();

    // Prevents user from taking screenshots. 
    getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // Load layout
    mWebView = new AIRWebView(this, this);
    mWebView.requestFocus(View.FOCUS_DOWN);

    setContentView(R.layout.activity_browser);
    FrameLayout layout = (FrameLayout) findViewById(R.id.sec_webview);
    layout.addView(((AIRWebView) mWebView).getLayout());

    // Initialize device monitoring 
    mDeviceStatus = new DeviceStatus(this, this);
    mDeviceStatus.registerReceivers(this);

    // By default, lock to landscape
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    mDeviceStatus.lockedOrientation = "landscape";

    // Configure the webview 
    configureWebView(mWebView);/*from ww  w . j  a v a  2  s.co  m*/

    // Configure Debug Console
    if (mIsDebugEnabled) {
        findViewById(R.id.slidingDrawer1).setVisibility(View.VISIBLE);
        findViewById(R.id.addressBarWrapper).setVisibility(View.VISIBLE);

        findViewById(R.id.goButton).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                String url = ((EditText) findViewById(R.id.address_bar)).getText().toString();
                mWebView.loadUrl(url);
            }
        });
    }

    // Load the content 
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

    String url = preferences.getString("pref_default_url", getString(R.string.url_default_location));

    // For testing, uncomment the following line to use a custom url: 

    // Check for Internet connectivity
    if (mDeviceStatus.connectivity == DeviceStatus.CONNECTIVITY_CONNECTED) {
        mWebView.loadUrl(url);
    } else {
        mWebView.loadUrl("about:none");
    }

    // Register BroadcastListener for service intents
    mSBReceiver = new SBReceiver(this);
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(super.getResources().getString(R.string.intent_black_logtag)));
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(super.getResources().getString(R.string.intent_micmutechanged)));
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(super.getResources().getString(R.string.intent_keyboardchange)));
    // add receiver for bluetooth keyboard connection/disconnection events
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
    LocalBroadcastManager.getInstance(super.getApplicationContext()).registerReceiver(mSBReceiver,
            new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED));

    IntentFilter testFilter = new IntentFilter(Intent.CATEGORY_HOME);

    super.getApplicationContext().registerReceiver(mSBReceiver, testFilter);

    // Get AudioManger
    mAudioManager = (AudioManager) super.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);

    // Configure JS Command Processing
    configureJSCmdHandling();

    // Begin monitoring for focus change. 
    startService(new Intent(getApplicationContext(), ActivityWatchService.class));
}

From source file:com.adityarathi.muo.services.AudioPlaybackService.java

/**
 * Prepares the MediaPlayer objects for first use 
 * and starts the service. The workflow of the entire 
 * service starts here.//from   w w w  .j  a v  a2s.c  om
 * 
 * @param intent Calling intent.
 * @param flags Service flags.
 * @param startId Service start ID.
 */
@SuppressLint("NewApi")
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);

    //Context.
    mContext = getApplicationContext();
    mService = this;
    mHandler = new Handler();

    mApp = (Common) getApplicationContext();
    mApp.setService((AudioPlaybackService) this);
    mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);

    //Initialize Google Analytics.
    initGoogleAnalytics();

    //Initialize the MediaPlayer objects.
    initMediaPlayers();

    //Time to play nice with other music players (and audio apps) and request audio focus.
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mAudioManagerHelper = new AudioManagerHelper();

    // Request audio focus for playback
    mAudioManagerHelper.setHasAudioFocus(requestAudioFocus());

    //Grab the crossfade duration for this session.
    mCrossfadeDuration = mApp.getCrossfadeDuration();

    //Initialize audio effects (equalizer, virtualizer, bass boost) for this session.
    initAudioFX();

    mMediaButtonReceiverComponent = new ComponentName(this.getPackageName(),
            HeadsetButtonsReceiver.class.getName());
    mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent);

    //if (mApp.getSharedPreferences().getBoolean(Common.SHOW_LOCKSCREEN_CONTROLS, true)==true) {
    //   initRemoteControlClient();
    //}

    mApp.getPlaybackKickstarter().setBuildCursorListener(buildCursorListener);

    //The service has been successfully started.
    setPrepareServiceListener(mApp.getPlaybackKickstarter());
    getPrepareServiceListener().onServiceRunning(this);

    return START_STICKY;
}

From source file:org.moire.ultrasonic.service.DownloadServiceImpl.java

@SuppressLint("NewApi")
@Override/*from w w  w  .  j a va2 s . c  om*/
public void onCreate() {
    super.onCreate();

    new Thread(new Runnable() {
        @Override
        public void run() {
            Thread.currentThread().setName("DownloadServiceImpl");

            Looper.prepare();

            if (mediaPlayer != null) {
                mediaPlayer.release();
            }

            mediaPlayer = new MediaPlayer();
            mediaPlayer.setWakeMode(DownloadServiceImpl.this, PowerManager.PARTIAL_WAKE_LOCK);

            mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
                @Override
                public boolean onError(MediaPlayer mediaPlayer, int what, int more) {
                    handleError(new Exception(String.format("MediaPlayer error: %d (%d)", what, more)));
                    return false;
                }
            });

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

            mediaPlayerLooper = Looper.myLooper();
            mediaPlayerHandler = new Handler(mediaPlayerLooper);
            Looper.loop();
        }
    }).start();

    audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
    setUpRemoteControlClient();

    if (equalizerAvailable) {
        equalizerController = new EqualizerController(this, mediaPlayer);
        if (!equalizerController.isAvailable()) {
            equalizerController = null;
        } else {
            equalizerController.loadSettings();
        }
    }
    if (visualizerAvailable) {
        visualizerController = new VisualizerController(mediaPlayer);
        if (!visualizerController.isAvailable()) {
            visualizerController = null;
        }
    }

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName());
    wakeLock.setReferenceCounted(false);

    instance = this;
    lifecycleSupport.onCreate();
}

From source file:ro.ciubex.keepscreenlock.MainApplication.java

/**
 * Called when the application is starting, before any activity, service,
 * or receiver objects (excluding content providers) have been created.
 *//*from  w  w w . j a  va 2  s . c o  m*/
@Override
public void onCreate() {
    super.onCreate();
    MainApplication.isEmulator = String.valueOf(Build.PRODUCT).startsWith("sdk");
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mDeviceManger = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    mComponentName = new ComponentName(this, AdminPermissionReceiver.class);
    mSdkInt = android.os.Build.VERSION.SDK_INT;
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    initLocale();
    checkKeepScreenLockReceiver();
}

From source file:dev.datvt.cloudtracks.song_player.PlayMusicActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    loadLocale();//  ww w . ja v  a 2  s .c  o m
    setContentView(R.layout.play_music_activity);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().setStatusBarColor(getResources().getColor(R.color.colorBlack));
    }

    MobileAds.initialize(getApplicationContext(), getResources().getString(R.string.app_id));
    interstitialAd = new InterstitialAd(this);
    interstitialAd.setAdUnitId(getResources().getString(R.string.ad_unit_full));
    requestNewInterstitial();

    interstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            super.onAdClosed();
            requestNewInterstitial();
        }
    });

    broadcastReceiver = new PlayerReciever();
    IntentFilter filter = new IntentFilter();
    filter.addAction(ConstantHelper.RESUME_SONG);
    filter.addAction(ConstantHelper.PAUSE_SONG);
    filter.addAction(ConstantHelper.NEXT_SONG);
    filter.addAction(ConstantHelper.PREVIOUS_SONG);
    filter.addAction(ConstantHelper.PLAY_SONG);
    filter.addAction(ConstantHelper.ACTION_COMPLETE_MUSIC);
    filter.addAction(ConstantHelper.ACTION_CLOSE_NOTI);
    registerReceiver(broadcastReceiver, filter);

    viewPager = (ViewPager) findViewById(R.id.viewPager);
    indicator = (CircleIndicator) findViewById(R.id.indicator);
    playMusicApdater = new PlayMusicApdater(getSupportFragmentManager());
    viewPager.setAdapter(playMusicApdater);
    indicator.setViewPager(viewPager);
    viewPager.setCurrentItem(1);

    indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            viewPager.setCurrentItem(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });

    ctx = getApplicationContext();
    if (MainActivity.mMediaPlayer != null) {
        mp = MainActivity.mMediaPlayer;
    } else {
        if (MediaPlayerService.mMediaPlayer != null) {
            mp = MediaPlayerService.mMediaPlayer;
        }
    }
    tracks = new ArrayList<>();
    audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);

    Intent intent = getIntent();
    if (intent != null) {
        curPos = intent.getIntExtra("pos", 0);
        repeat = intent.getIntExtra("rep", REP);
        isPlaying = intent.getBooleanExtra("isPlay", isPlaying);
        isStop = intent.getBooleanExtra("isStop", isStop);
        Log.d("isPLAY", isPlaying + "");
        Log.d("CUR_POS", curPos + "");
    }

    initiate();

    if (MainActivity.tracks != null) {
        tracks = MainActivity.tracks;

        if (tracks.size() > curPos) {
            curTrack = tracks.get(curPos);

            if (curTrack.bpm != ToolsHelper.IS_LOCAL && isStop) {
                loadingUpdate.setVisibility(View.VISIBLE);
                loadingUpdate.progressiveStart();
            }
        }
    }

    if (isPlaying) {
        Log.d("OPEN", "RUNNING");
        isStop = false;
        if (mHandler == null) {
            Log.d("HANDLE", "NULL");
        }
        mHandler.postDelayed(mUpdateTimeTask, DUR);
        pp.setImageResource(R.drawable.custom_pause);
    } else {
        Log.d("OPEN", "PAUSE");
        mHandler.postDelayed(mUpdateTimeTask, DUR);
        pp.setImageResource(R.drawable.custom_play);
    }
}

From source file:com.brayanarias.alarmproject.activity.AlarmScreenActivity.java

private void playRingtone(String tone) {
    mediaPlayer = new MediaPlayer();
    try {// www  .j ava2  s.co m
        Uri ringtoneUri;
        if (tone.equals("default")) {
            ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
        } else {
            ringtoneUri = Uri.parse(tone);
        }

        if (ringtoneUri != null) {
            mediaPlayer.setDataSource(this, ringtoneUri);
            mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
            mediaPlayer.setLooping(true);
            mediaPlayer.prepare();
            AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            actualVolume = audioManager.getStreamVolume(AudioManager.STREAM_ALARM);
            incrementVolume();
            mediaPlayer.start();
            audioManager.setStreamVolume(AudioManager.STREAM_ALARM, 1, 0);
        }
    } catch (Exception e) {
        Log.e(tag, e.getLocalizedMessage(), e);
    }
}

From source file:com.example.android.wearable.speaker.MainActivity.java

/**
 * Determines if the wear device has a built-in speaker and if it is supported. Speaker, even if
 * physically present, is only supported in Android M+ on a wear device..
 *///from  ww w .j  a va2s .co m
public final boolean speakerIsSupported() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        PackageManager packageManager = getPackageManager();
        // The results from AudioManager.getDevices can't be trusted unless the device
        // advertises FEATURE_AUDIO_OUTPUT.
        if (!packageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT)) {
            return false;
        }
        AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
        for (AudioDeviceInfo device : devices) {
            if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
                return true;
            }
        }
    }
    return false;
}

From source file:com.squalala.talkiewalkie.ui.activities.TalkActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_talk);
    ButterKnife.bind(this);

    connectedUserFragment = new ConnectedUserFragment();
    settingsFragment = new SettingsFragment();

    messageAdapter = new MessageAdapter(messages, new OnClickMessageListener() {
        @Override//from  w w w.j a v  a2s . c  om
        public void onClickMessage(Message message) {
            message.setRead(false);
            recyclerView.getAdapter().notifyDataSetChanged();
            mMessages.add(message);
            playAudios();
        }
    });

    linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setStackFromEnd(true);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(messageAdapter);

    progressView.setVisibility(View.VISIBLE);
    btnUserOnline.setVisibility(View.GONE);
    txtWhatHappen.setVisibility(View.GONE);
    //    txtNumberUsers.setVisibility(View.GONE);
    txtWhoSpeak.setVisibility(View.GONE);

    session = ((App) getApplication()).getSession();
    mSocket = ((App) getApplication()).getSocket();
    mSocket.on(Socket.EVENT_CONNECT, onConnect);
    mSocket.on(Socket.EVENT_DISCONNECT, onDisconnect);
    mSocket.on(Socket.EVENT_CONNECT_ERROR, onConnectError);
    mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, onConnectError);
    mSocket.on(KEY_NEW_MESSAGE, onNewMessage);
    mSocket.on(KEY_JOIN_ROOM, onJoinRoom);
    mSocket.on(KEY_LEFT_ROOM, onLeftRoom);
    mSocket.on(KEY_NUMBER_USERS, onNumberUsers);
    mSocket.on(KEY_CONNECTED_USERS, onConnectedUsers);

    mSocket.connect();
    /*
            if (session.isBeep())
    iconBeep.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_volume_up_black_48dp));
            else
    iconBeep.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_volume_off_black_48dp));  */

    amanager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);

    //   int maxVolume = amanager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);

    //  System.out.println("Max volume " + maxVolume);
    //  System.out.println("session Max volume " + session.getSoundVolume());
    amanager.setStreamVolume(AudioManager.STREAM_MUSIC, session.getSoundVolume(amanager), 0);

    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mediaPlayerForBeep.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);

    mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @DebugLog
        @Override
        public void onCompletion(MediaPlayer mediaPlayer) {
            viewAvatar.setVisibility(View.GONE);
            //  pulsator.stop();

            if (session.isAutomaticPlay())
                playAudios();
        }
    });

    mIvVoiceIndicators = new ArrayList<>();
    mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator1));
    mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator2));
    mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator3));
    mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator4));
    mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator5));
    mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator6));
    mIvVoiceIndicators.add(ButterKnife.<ImageView>findById(this, R.id.mIvVoiceIndicator7));

    mAudioRecorder = AudioRecorder.getInstance();
    mRxAudioPlayer = RxAudioPlayer.getInstance();
    mAudioRecorder.setOnErrorListener(this);

    btnSpeak.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                press2Record();
                break;
            case MotionEvent.ACTION_UP:
                release2Send();
                break;
            case MotionEvent.ACTION_CANCEL:
                release2Send();
                break;
            default:
                break;
            }

            return true;
        }
    });
}

From source file:com.rexmtorres.android.patternlock.PatternLockView.java

@SuppressWarnings("deprecation")
public PatternLockView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mContext = getContext();//from w w  w. ja  va 2 s  . c  om

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PatternLockView,
            R.attr.patternLockViewStyle, 0);
    final String aspect = a.getString(R.styleable.PatternLockView_aspect);
    if ("square".equals(aspect)) {
        mAspect = ASPECT_SQUARE;
    } else if ("lock_width".equals(aspect)) {
        mAspect = ASPECT_LOCK_WIDTH;
    } else if ("lock_height".equals(aspect)) {
        mAspect = ASPECT_LOCK_HEIGHT;
    } else {
        mAspect = ASPECT_SQUARE;
    }
    setClickable(true);
    mPathPaint.setAntiAlias(true);
    mPathPaint.setDither(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        mRegularColor = context.getColor(R.color.lock_pattern_view_regular_color);
        mErrorColor = context.getColor(R.color.lock_pattern_view_error_color);
        mSuccessColor = context.getColor(R.color.lock_pattern_view_success_color);
    } else {
        Resources resources = context.getResources();

        mRegularColor = resources.getColor(R.color.lock_pattern_view_regular_color);
        mErrorColor = resources.getColor(R.color.lock_pattern_view_error_color);
        mSuccessColor = resources.getColor(R.color.lock_pattern_view_success_color);
    }

    mRegularColor = a.getColor(R.styleable.PatternLockView_regularColor, mRegularColor);
    mErrorColor = a.getColor(R.styleable.PatternLockView_errorColor, mErrorColor);
    mSuccessColor = a.getColor(R.styleable.PatternLockView_successColor, mSuccessColor);

    int pathColor = a.getColor(R.styleable.PatternLockView_pathColor, mRegularColor);

    // [START rexmtorres 20160401] If set, replaces the pattern dots with the specified bitmap.
    Drawable oDotDrawable = a.getDrawable(R.styleable.PatternLockView_dotBitmap);

    if (oDotDrawable != null) {
        if (oDotDrawable instanceof BitmapDrawable) {
            m_oDotBitmap = ((BitmapDrawable) oDotDrawable).getBitmap();
            m_oBigDotBitmap = Bitmap.createScaledBitmap(m_oDotBitmap, (int) (m_oDotBitmap.getWidth() * 1.25),
                    (int) (m_oDotBitmap.getHeight() * 1.25), false);
        }
    }
    // [END rexmtorres 20160401]

    a.recycle();

    mPathPaint.setColor(pathColor);
    mPathPaint.setStyle(Paint.Style.STROKE);
    mPathPaint.setStrokeJoin(Paint.Join.ROUND);
    mPathPaint.setStrokeCap(Paint.Cap.ROUND);
    mPathWidth = getResources().getDimensionPixelSize(R.dimen.lock_pattern_dot_line_width);
    mPathPaint.setStrokeWidth(mPathWidth);
    mDotSize = getResources().getDimensionPixelSize(R.dimen.lock_pattern_dot_size);
    mDotSizeActivated = getResources().getDimensionPixelSize(R.dimen.lock_pattern_dot_size_activated);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mCellStates = new CellState[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            mCellStates[i][j] = new CellState();
            mCellStates[i][j].radius = mDotSize / 2;
            mCellStates[i][j].row = i;
            mCellStates[i][j].col = j;
            mCellStates[i][j].bitmapDot = m_oDotBitmap;
        }
    }

    mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
    mLinearOutSlowInInterpolator = new LinearOutSlowInInterpolator();
    mExploreByTouchHelper = new PatternExploreByTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper);
    mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
}

From source file:com.rks.musicx.services.MusicXService.java

private void otherstuff() {
    recent = new CommonDatabase(this, Constants.RecentlyPlayed_TableName, true);
    queue = new CommonDatabase(this, Constants.Queue_TableName, true);
    CurrentSong = new Song();
    audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    checkTelephonyState();//from   w  w w .j av a 2  s.co m
    headsetState();
    mediaLockscreen();
    restoreState();
    mediaButtonReceiver = new MediaButtonReceiver();
    if (controlReceiver == null) {
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY);
        intentFilter.addAction(ACTION_PREVIOUS);
        intentFilter.addAction(ACTION_PAUSE);
        intentFilter.addAction(ACTION_PLAY);
        intentFilter.addAction(ACTION_TOGGLE);
        intentFilter.addAction(ACTION_NEXT);
        intentFilter.addAction(ACTION_CHANGE_STATE);
        intentFilter.addAction(ACTION_COMMAND1);
        intentFilter.addAction(ACTION_COMMAND);
        intentFilter.addAction(ACTION_FAV);
        registerReceiver(controlReceiver, intentFilter);
        registerReceiver(mediaButtonReceiver, intentFilter);
        Log.d(TAG, "Broadcast");
    }
    if (permissionManager.isAudioRecordGranted(this)) {
        int audioID = audioSession();
        Equalizers.initEq(audioID);
        BassBoosts.initBass(audioID);
        Virtualizers.initVirtualizer(audioID);
        Loud.initLoudnessEnhancer(audioID);
        Reverb.initReverb();
    } else {
        Log.d(TAG, "permission not granted");
    }
    favHelper = new FavHelper(this);
    handler = new Handler();
    helper = new Helper(this);
    if (permissionManager.isSystemAlertGranted(MusicXService.this)) {
        widgetPermission = true;
    } else {
        widgetPermission = false;
        Log.d(TAG, "Overlay permission not detected");
    }
}