Context 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 Context getSystemService method.

This code example shows how to use the following methods:getBroadcast, getSystemService, getDefaultSharedPreferences
  @Override 
  public void onReceive(Context context, Intent intent) {
    Log.w("DirectoryUpdateReceiver", "Initiating scheduled directory update...");
 
    try { 
      SignalingSocket signalingSocket = new SignalingSocket(context);
      DirectoryResponse response      = signalingSocket.getNumberFilter();
 
      if (response != null) {
        NumberFilter filter = new NumberFilter(response.getFilter(), response.getHashCount());
        filter.serializeToFile(context);
      } 
    } catch (SignalingException se) {
      Log.w("DirectoryUpdateReceiver", se);
    } catch (Exception e) {
      Log.w("DirectoryUpdateReceiver", e);
      return; 
    } 
 
    scheduleDirectoryUpdate(context);

9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBroadcast, getSystemService
                ", error = " + error + ", removed = " + removed);
        } 
 
        if (removed != null) {
            // Remember we are unregistered 
            C2DMessaging.clearRegistrationId(context);
            onUnregistered(context);
            return; 
        } else if (error != null) {
            // we are not registered, can try again 
            C2DMessaging.clearRegistrationId(context);
            // Registration failed 
            Log.e(TAG, "Registration error " + error);
            onError(context, error);
            if ("SERVICE_NOT_AVAILABLE".equals(error)) {
                long backoffTimeMs = C2DMessaging.getBackoff(context);
                 
                Log.d(TAG, "Scheduling registration retry, backoff = " + backoffTimeMs);
                Intent retryIntent = new Intent(C2DM_RETRY);
                PendingIntent retryPIntent = PendingIntent.getBroadcast(context, 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBroadcast, getMainLooper, getSystemService
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBroadcast, getSharedPreferences, getSystemService
     */ 
    public void onRegistered(Context context, String registrationId) throws IOException {
        // registrationId will also be saved 
    } 
 
    /** 
     * Called when the device has been unregistered. 
     */ 
    public void onUnregistered(Context context) {
    } 
 
     
    @Override 
    public final void onHandleIntent(Intent intent) {
        try { 
            Context context = getApplicationContext();
            if (intent.getAction().equals(REGISTRATION_CALLBACK_INTENT)) {
                handleRegistration(context, intent);
            } else if (intent.getAction().equals(C2DM_INTENT)) {
                onMessage(context, intent);

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getSystemService
     *  @param contentText	Notification text 
     * */ 
    public void showNotification( CharSequence tag, CharSequence contentTitle, CharSequence contentText, int flag) {
        String ns = Context.NOTIFICATION_SERVICE;
        context = cordova.getActivity().getApplicationContext();
        mNotificationManager = (NotificationManager) context.getSystemService(ns);
 
        Notification noti = StatusNotificationIntent.buildNotification(context, tag, contentTitle, contentText, flag);
        mNotificationManager.notify(tag.hashCode(), noti);
    } 
 
    /** 
     * Cancels a single notification by tag. 
     * 
     * @param tag Notification tag to cancel. 
     */ 
    public void clearNotification(String tag) {
        mNotificationManager.cancel(tag.hashCode());
    } 
 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getContentResolver, getSystemService
    return shouldVibrateOld(context);
  } 
 
  @SuppressLint("NewApi") 
  private boolean shouldVibrateNew(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
 
    if (vibrator == null || !vibrator.hasVibrator()) {
      return false; 
    } 
 
    boolean vibrateWhenRinging = Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing", 0) != 0;
    int ringerMode = audioManager.getRingerMode();
    if (vibrateWhenRinging) {
      return ringerMode != AudioManager.RINGER_MODE_SILENT;
    } else { 
      return ringerMode == AudioManager.RINGER_MODE_VIBRATE;
    } 
  } 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getActivity, getSystemService
{ 
	@Override 
	public void onReceive(Context context, Intent intent)
	{ 
	    NotificationManager manger = (NotificationManager) context
	            .getSystemService(context.NOTIFICATION_SERVICE);
 
		Intent mainIntent = new Intent("ti.intent.action.calendar.ALARM");
 
	    Notification notification = new Notification(0x7f020000,
	            "", System.currentTimeMillis());
	    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
	            mainIntent, 0);
	//TEST 
		notification.setLatestEventInfo(context,"Payment Reminder","Send me to jhaynie@appcelerator.com",contentIntent);
	    manger.notify(1, notification);
	} 
} 
 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getSystemService, startActivity
    void startCallActivity() { 
        sendCloseSystemWindows(); 
        Intent intent = new Intent(Intent.ACTION_CALL_BUTTON);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try { 
            mContext.startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Slog.w(TAG, "No activity found for android.intent.action.CALL_BUTTON.");
        } 
    } 
 
    SearchManager getSearchManager() {
        if (mSearchManager == null) {
            mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
        } 
        return mSearchManager;
    } 
 
    TelephonyManager getTelephonyManager() {
        if (mTelephonyManager == null) {

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getApplicationInfo, getPackageName, getResources, getSystemService
/* 
*    This file is part of GPSLogger for Android. 
* 
*    GPSLogger for Android is free software: you can redistribute it and/or modify 
*    it under the terms of the GNU General Public License as published by 
*    the Free Software Foundation, either version 2 of the License, or 
*    (at your option) any later version. 
* 
*    GPSLogger for Android is distributed in the hope that it will be useful, 
*    but WITHOUT ANY WARRANTY; without even the implied warranty of 
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
*    GNU General Public License for more details. 
* 
*    You should have received a copy of the GNU General Public License 
*    along with GPSLogger for Android.  If not, see <http://www.gnu.org/licenses/>. 
*/ 
 
package com.mendhak.gpslogger.senders.gdocs; 
 
import android.content.Context; 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getService, getSystemService
            Toast.makeText(context, context.getString(R.string.start_fetch_msg), Toast.LENGTH_SHORT).show();
        } 
    } 
 
    public static void stopAlarm(Context context, boolean clearNotification) {
        AlarmManager alarm = (AlarmManager) context.getSystemService(
                Context.ALARM_SERVICE);
        Intent intent = new Intent(context, FetchNewMsgService.class);
        PendingIntent sender = PendingIntent.getService(context, REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        alarm.cancel(sender);
        if (clearNotification) {
            NotificationManager notificationManager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.cancel(Long.valueOf(GlobalContext.getInstance().getCurrentAccountId()).intValue());
        } 
    } 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Context getSystemService Questions & Answers:

Other Context getSystemService Examples

13:	
14:		public boolean isConnectingToInternet(){
15:			ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
16:			  if (connectivity != null) 
17:			  {

Read More

43:			if (convertView == null) {
44:	            LayoutInflater mInflater = (LayoutInflater)
45:	                    context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
46:	            convertView = mInflater.inflate(R.layout.drawer_list_item, null);
47:	        }

Read More

16:	     * **/
17:	    public boolean isConnectingToInternet(){
18:	        ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
19:	          if (connectivity != null)
20:	          {

Read More

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