Activity getSystemService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Activity getSystemService method.

This code example shows how to use the following methods:getSystemService, getResources
		if (collection == null) {
			this.collection = new GCAccountMediaCollection();
		} else { 
			this.collection = collection;
		} 
		loader = ImageLoader.getLoader(context);
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		displayMetrics = context.getResources().getDisplayMetrics();
	} 
 
	@Override 
	public int getCount() { 
		return collection.size();
	} 
 
	@Override 
	public GCAccountMediaModel getItem(int position) {
		return collection.get(position);
	} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService, setVolumeControlStream, getClass
	 
	public void disableKeyguard(Activity activity) {
		if (mKeyguardLock != null) {
			mKeyguardLock.disableKeyguard();
		} else { 
			KeyguardManager keyguardManager = (KeyguardManager) activity.getSystemService(Activity.KEYGUARD_SERVICE);
			mKeyguardLock = keyguardManager.newKeyguardLock(KEYGUARD_TAG);
			mKeyguardLock.disableKeyguard();
		} 
	} 
	 
	public void enableKeyguard() { 
		if (mKeyguardLock != null) {
			mKeyguardLock.reenableKeyguard();
		} 
		mKeyguardLock = null;
	} 
 
 
	public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService, getWindowManager
	private float[] geoMag = new float[3];
	private boolean rotateOrientation;
	private Display display;
 
	public AccelerometerListener(Activity activity) {
		sensorManager = (SensorManager) activity.getSystemService(Activity.SENSOR_SERVICE);
		accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
		display = activity.getWindowManager().getDefaultDisplay();
		updateOrientationInfo(); 
	} 
	 
	private void updateOrientationInfo() { 
		rotateOrientation = (display.getOrientation() == Surface.ROTATION_90) ? true : false;
	} 
 
	public float getX() { 
		return (rotateOrientation) ? gravs[1] :-gravs[0];
	} 
 
	public float getY() { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService
	} 
 
	@Override 
	public boolean dispatchKeyEventPreIme ( KeyEvent event ) {
		if ( activityReference != null ) {
			InputMethodManager imm = ( InputMethodManager ) activityReference.getSystemService ( Context.INPUT_METHOD_SERVICE );
			if ( imm.isActive () && event.getKeyCode () == KeyEvent.KEYCODE_BACK ) {
				MoaiLog.i ( "LinearLayoutIMETrap dispatchKeyEventPreIme, event: " + event );
				MoaiKeyboard.hideKeyboard (); // hide the keyboard if its visible .. 
				if ( Moai.backButtonPressed ()) { 
					return true; 
				} 
			} 
		} 
 
		return super.dispatchKeyEventPreIme ( event );
	} 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService
  void playBeepSoundAndVibrate() { 
    if (playBeep && mediaPlayer != null) {
      mediaPlayer.start();
    } 
    if (vibrate) {
      Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
      vibrator.vibrate(VIBRATE_DURATION);
    } 
  } 
 
  private static boolean shouldBeep(SharedPreferences prefs, Context activity) {
    boolean shouldPlayBeep = prefs.getBoolean(PreferencesActivity.KEY_PLAY_BEEP, true);
    if (shouldPlayBeep) {
      // See if sound settings overrides this 
      AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
      if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
        shouldPlayBeep = false;
      } 
    } 
    return shouldPlayBeep;
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService, getAssets
	private static float globalVolume = 1.0f;
	private String currentTrack = "";
 
	public MediaStreamManager(Activity activity) {
		this.activity = activity;
		this.manager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
		this.assets = activity.getAssets();
	} 
 
	public static void setGlobalVolume(float volume) {
		globalVolume = volume;
		setVolume(volume);
	} 
 
	public static float getGlobalVolume() { 
		return globalVolume;
	} 
 
	public boolean load(String fileName) {
		// dummy (will be loaded on play time) 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService
		return null; 
	} 
 
	public Object getSystemService(final String name) {
		final Activity activity = getActivity();
		if (activity != null) return activity.getSystemService(name);
		return null; 
	} 
 
	public void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
		final Activity activity = getActivity();
		if (activity == null) return;
		activity.registerReceiver(receiver, filter);
	} 
 
	public void setProgressBarIndeterminateVisibility(final boolean visible) {
		final Activity activity = getActivity();
		if (activity instanceof BaseActivity) {
			((BaseActivity) activity).setSupportProgressBarIndeterminateVisibility(visible);
		} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCurrentFocus, getSystemService
		cDef.set(Calendar.MINUTE, 0);
		return cDef;
	} 
 
	public static void hideInput(Activity activity) {
		if (activity.getCurrentFocus() != null) {
			InputMethodManager inputMethodManager = (InputMethodManager) activity
					.getSystemService(Context.INPUT_METHOD_SERVICE);
			inputMethodManager.hideSoftInputFromWindow(activity
					.getCurrentFocus().getWindowToken(),
					InputMethodManager.HIDE_NOT_ALWAYS);
		} 
	} 
 
	public static Uri saveLocalFile(Context context, int index) {
		String filename = DownloadUtils.SAVE_PATH
				+ String.format("%d.png", index);
		File fLocal = new File(filename);
		if (fLocal.exists()) {
			return Uri.fromFile(new File(filename));
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService
		return null; 
	} 
 
	public Object getSystemService(final String name) {
		final Activity activity = getActivity();
		if (activity != null) return activity.getSystemService(name);
		return null; 
	} 
 
	public AsyncTwitterWrapper getTwitterWrapper() { 
		return getApplication() != null ? getApplication().getTwitterWrapper() : null; 
	} 
 
	public void invalidateOptionsMenu() { 
		final FragmentActivity activity = getActivity();
		if (activity == null) return;
		if (activity instanceof BaseActivity) {
			((BaseActivity) activity).invalidateSupportOptionsMenu();
		} else { 
			activity.supportInvalidateOptionsMenu();
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemService

Related Activity getSystemService Questions & Answers:

Other Activity getSystemService Examples

30:	        .addAction(R.drawable.icon, "More", pIntent)
31:	        .addAction(R.drawable.icon, "And more", pIntent).build();
32:	    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
33:	    // hide the notification after its selected
34:	    noti.flags |= Notification.FLAG_AUTO_CANCEL;

Read More

25:	
26:	    // Get the location manager
27:	    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
28:	    // Define the criteria how to select the locatioin provider -> use
29:	    // default

Read More

23:	    setContentView(compassView);
24:	
25:	    sensorService = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
26:	    sensor = sensorService.getDefaultSensor(Sensor.TYPE_ORIENTATION);
27:	    if (sensor != null) {

Read More

4:	
5:			// Associate searchable configuration with the SearchView
6:			SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
7:			SearchView searchView = (SearchView) menu.findItem(R.id.action_search)
8:					.getActionView();

Read More

46:	 
47:	        inflater = (LayoutInflater) _activity
48:	                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
49:	        View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container,
50:	                false);

Read More

68:	
69:						// Hiding the keyboard
70:						InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
71:						imm.hideSoftInputFromWindow(inputLabel.getWindowToken(), 0);
72:

Read More

getSystemService Method Overview
Return the handle to a system-level service by name.
See Code Examples for other Android Activity Methods: