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.example.chu.googleplaylibrary.playback.LocalPlayback.java
public LocalPlayback(Context context, String mMusicProvider) { this.mContext = context; this.mMusicProvider = mMusicProvider; this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "uAmp_lock"); this.mState = PlaybackStateCompat.STATE_NONE; }
From source file:com.air.mobilebrowser.ActivityWatchService.java
@Override public void onCreate() { super.onCreate(); //Create an application whitelist, by default, we include android :-) mApplicationWhitelist = new ArrayList<String>(); mApplicationWhitelist.add("android"); String[] blackApps = super.getResources().getStringArray(R.array.blacklist_apps); for (String bapp : blackApps) { mAppBlacklist.add(bapp);// w ww. j av a 2 s . co m } // For Android 5, also add com.google.android.music:main to the block list. // We need to detect if music is being played while the browser is running. // This process is shown on Android 5 only when the music is being played, while for // older Androids, the process list does not reflect whether music is being played or not if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.KITKAT) { String musicAppProcess = "com.google.android.music:main"; mAppBlacklist.add(musicAppProcess); } //Save current keyboard mLastKeyboard = KeyboardUtil.getKeyboardPackage(super.getContentResolver()); mClipboardManager = (ClipboardManager) super.getSystemService(Context.CLIPBOARD_SERVICE); //Save current keyboard mLastKeyboard = KeyboardUtil.getKeyboardPackage(super.getContentResolver()); //Get a reference to the AudioManager to check mic mute status mAudioManager = (AudioManager) super.getApplicationContext().getSystemService(Context.AUDIO_SERVICE); mMicMute = mAudioManager.isMicrophoneMute(); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setWhen(System.currentTimeMillis()); builder.setTicker("Secure Browser"); builder.setSmallIcon(android.R.drawable.alert_light_frame); builder.setOngoing(true); startForeground(SERVICE_ID, builder.build()); }
From source file:com.zuluindia.watchpresenter.MonitorVolumeKeyPress.java
public void onCreate() { super.onCreate(); settings = getSharedPreferences(Constants.SETTINGS_NAME, MODE_PRIVATE); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); Log.d(LOGCAT, "Service Started!"); objPlayer = MediaPlayer.create(this, com.zuluindia.watchpresenter.R.raw.silence); objPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); objPlayer.setLooping(true);/* w w w . j a va 2 s . c om*/ timer = new Timer(); audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); midVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) / 2; resetVolume(); }
From source file:com.example.android.mediabrowserservice.Playback.java
public Playback(MusicService service, MusicProvider musicProvider) { this.mService = service; this.mMusicProvider = musicProvider; this.mAudioManager = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) service.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "sample_lock"); }
From source file:com.example.android.supportv4.media.Playback.java
public Playback(MediaBrowserServiceSupport service, MusicProvider musicProvider) { this.mService = service; this.mMusicProvider = musicProvider; this.mAudioManager = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) service.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "sample_lock"); }
From source file:com.appdevper.mediaplayer.app.LocalPlayback.java
public LocalPlayback(MusicService service, MusicProvider musicProvider) { this.mService = service; this.mMusicProvider = musicProvider; this.mAudioManager = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) service.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "uAmp_lock"); }
From source file:com.hari.autotasx.GeofenceTransitionsIntentService.java
@Override protected void onHandleIntent(Intent intent) { GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent); if (geofencingEvent.hasError()) { String errorMessage = GeofenceErrorMessages.getErrorString(this, geofencingEvent.getErrorCode()); // Log.e(TAG, errorMessage); return;/*from w w w. ja v a 2s. c o m*/ } int geofenceTransition = geofencingEvent.getGeofenceTransition(); int smsDb = 0; int wifiDb = 0; int silDb = 0; int RemDb = 0; int blueDb = 0; int carDb = 0; String remMsgDb = null; int RemDb_carPark = 0; String remMsgDb_carPark = null; //Creating database object to fetch values ManageDB autodb = new ManageDB(this); autodb.open(); if (!CarParkService.car_flag_static) { Cursor cursor = autodb.getEntry(ActionFragment.geoFence); cursor.moveToFirst(); //System.out.println("cursor count"+cursor.getCount()); //Log.i("logcat",cursor.getString(0)+", "+cursor.getString(1)+" , "+cursor.getString(2)); smsDb = cursor.getInt(5); wifiDb = cursor.getInt(6); silDb = cursor.getInt(7); RemDb = cursor.getInt(8); remMsgDb = cursor.getString(9); blueDb = cursor.getInt(10); carDb = cursor.getInt(11); cursor.close(); } else { Cursor cursor_carpark = autodb.getEntryCarPark(CarParkService.geofence_carpark); cursor_carpark.moveToFirst(); carDb = cursor_carpark.getInt(11); remMsgDb_carPark = cursor_carpark.getString(9); cursor_carpark.close(); } autodb.close(); //Checking Enter/Exit transitions if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) { List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences(); String geofenceTransitionDetails = getGeofenceTransitionDetails(this, geofenceTransition, triggeringGeofences); System.out.println("smsdb" + smsDb); if (RemDb == 1) { sendNotification(geofenceTransitionDetails, remMsgDb); } if (carDb == 1) { sendNotification(geofenceTransitionDetails, remMsgDb_carPark); } //Perform actions if set on Actions set if (silDb == 1) { Toast.makeText(this, "silent", Toast.LENGTH_SHORT).show(); AudioManager am = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE); am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); } if (wifiDb == 1) { WifiManager wifiManager = (WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE); wifiManager.setWifiEnabled(true); } if (blueDb == 1) { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!mBluetoothAdapter.isEnabled()) { mBluetoothAdapter.enable(); } } if (smsDb == 1) { Toast.makeText(this, "inside sendsms()", Toast.LENGTH_SHORT).show(); SmsManager sm = SmsManager.getDefault(); System.out.printf("sm", sm); sm.sendTextMessage(ActionFragment.smsNo, null, "Hi, I am in " + ActionFragment.geoFence.getNameLoc() + " now!!!!", null, null); } if (carDb == 1) { Intent mapIntent = new Intent(this, CarParkMap.class); mapIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } } else if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) { List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences(); String geofenceTransitionDetails = getGeofenceTransitionDetails(this, geofenceTransition, triggeringGeofences); if (silDb == 1) { Toast.makeText(this, "general", Toast.LENGTH_SHORT).show(); AudioManager am1 = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE); am1.setRingerMode(AudioManager.RINGER_MODE_NORMAL); } if (wifiDb == 1) { WifiManager wifiManager1 = (WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE); wifiManager1.setWifiEnabled(false); } if (blueDb == 1) { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter.isEnabled()) { mBluetoothAdapter.disable(); } } if (smsDb == 1) { Toast.makeText(this, "inside sendsms()", Toast.LENGTH_SHORT).show(); SmsManager sm = SmsManager.getDefault(); System.out.printf("smsNo :" + ActionFragment.smsNo); //fetch sm.sendTextMessage(ActionFragment.smsNo, null, "Hi, I am outside " + ActionFragment.geoFence.getNameLoc() + " now !!!", null, null); } if (RemDb == 1) { sendNotification(geofenceTransitionDetails, remMsgDb); } } }
From source file:com.sourceauditor.sahomemonitor.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = getApplicationContext();/*from w w w . j av a2 s . c o m*/ prefs = getSAHomeMonitorPreferences(context); setContentView(R.layout.activity_main); audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); playPauseButton = (Button) findViewById(R.id.playpause); playPauseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (paused()) { play(); } else { pause(); } } }); registerGcm(); }
From source file:dk.glutter.android.knr.playback.LocalPlayback.java
public LocalPlayback(Context context, MusicProvider musicProvider) { this.mContext = context; this.mMusicProvider = musicProvider; this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "knr_lock"); this.mState = PlaybackStateCompat.STATE_NONE; }
From source file:org.amahi.anywhere.service.AudioService.java
private void setUpAudioPlayerRemote() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); ComponentName audioReceiver = new ComponentName(getPackageName(), AudioReceiver.class.getName()); Intent audioIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); audioIntent.setComponent(audioReceiver); PendingIntent audioPendingIntent = PendingIntent.getBroadcast(this, 0, audioIntent, 0); audioPlayerRemote = new RemoteControlClient(audioPendingIntent); audioPlayerRemote.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS); audioPlayerRemote.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); audioManager.registerMediaButtonEventReceiver(audioReceiver); audioManager.registerRemoteControlClient(audioPlayerRemote); }