Android PendingIntent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android PendingIntent class.

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
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
This code example shows how to use the following methods:getBroadcast, getMainLooper, getSystemService
9
CodeRank
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
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
This code example shows how to use the following methods:getActivity, getApplicationContext, getClass
 
	private MoSyncNFCForegroundUtil(Activity activity, NfcAdapter nfc) {
	    this.activity = activity;
	    this.nfc = nfc;
 
	    intent = PendingIntent.getActivity(activity, 0, new Intent(activity, activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
 
	    // TODO: NDEF!? 
	    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
 
//	    try { 
//	        ndef.addDataType("*/*"); 
//	    } catch (MalformedMimeTypeException e) { 
//	        throw new RuntimeException("Unable to speciy */* Mime Type", e); 
//	    } 
 
	    intentFilters = new IntentFilter[] { ndef };
 
	    // TODO: READ FROM NFC.XML OR SMTHG 
	    techLists = new String[][] {

8
CodeRank
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
This code example shows how to use the following methods:getBroadcast, getSharedPreferences, getSystemService
    scheduleAlarms(listener, ctxt, true);
  } 
 
  public static void scheduleAlarms(AlarmListener listener,
                                    Context ctxt, boolean force) {
    SharedPreferences prefs=ctxt.getSharedPreferences(NAME, 0);
    long lastAlarm=prefs.getLong(LAST_ALARM, 0);
 
    if (lastAlarm == 0
        || force
        || (System.currentTimeMillis() > lastAlarm && System.currentTimeMillis()
            - lastAlarm > listener.getMaxAge())) {
      AlarmManager mgr=
          (AlarmManager)ctxt.getSystemService(Context.ALARM_SERVICE);
      Intent i=new Intent(ctxt, AlarmReceiver.class);
      PendingIntent pi=PendingIntent.getBroadcast(ctxt, 0, i, 0);
 
      listener.scheduleAlarms(mgr, pi, ctxt);
    } 
  } 

8
CodeRank
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
This code example shows how to use the following methods:getService, getSystemService, getDefaultSharedPreferences
        } 
	} 
	 
	public static void setAlarm(Context context) {
		PendingIntent alarmSender;
		alarmSender = PendingIntent.getService(context, 0, new Intent(context, AutoRefreshService.class), PendingIntent.FLAG_UPDATE_CURRENT);
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        boolean autoUpdatesEnabled = prefs.getBoolean("autoupdates_enabled", true);
        Integer refreshRate = Integer.parseInt(prefs.getString("refresh_rate", "0")); 
        AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        if (!autoUpdatesEnabled) {
        	am.cancel(alarmSender);
        } 
        else { 
	        long firstTime = SystemClock.elapsedRealtime();
	        int secondsInMinute = 60;
	        if (prefs.getBoolean("debug_mode", false) && prefs.getBoolean("debug_refreshrate_in_seconds", false)) {
	            secondsInMinute = 1;
	        } 
	        am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime+refreshRate*secondsInMinute*1000, refreshRate*secondsInMinute*1000, alarmSender);

7
CodeRank

Related Android PendingIntent Questions & Answers:

Other Android PendingIntent Examples

19:	    // notification is selected
20:	    Intent intent = new Intent(this, NotificationReceiverActivity.class);
21:	    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
22:	
23:	    // Build notification

Read More

100:	        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
101:	                Intent.FLAG_ACTIVITY_SINGLE_TOP);
102:	        PendingIntent intent =
103:	                PendingIntent.getActivity(context, 0, notificationIntent, 0);
104:	        notification.setLatestEventInfo(context, title, message, intent);

Read More

See Code Examples for Android PendingIntent Methods: