List of usage examples for android.app PendingIntent getService
public static PendingIntent getService(Context context, int requestCode, @NonNull Intent intent, @Flags int flags)
From source file:can.yrt.onebusaway.tripservice.NotifierTask.java
private Notification createNotification(Uri alertUri) { //Log.d(TAG, "Creating notification for alert: " + alertUri); Intent deleteIntent = new Intent(mContext, TripService.class); deleteIntent.setAction(TripService.ACTION_CANCEL); deleteIntent.setData(alertUri);//from w ww . ja v a2s. c om return new NotificationCompat.Builder(mContext).setSmallIcon(R.drawable.ic_stat_notification) .setDefaults(Notification.DEFAULT_ALL).setOnlyAlertOnce(true) //.setLights(0xFF00FF00, 1000, 1000) //.setVibrate(VIBRATE_PATTERN) .setDeleteIntent( PendingIntent.getService(mContext, 0, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT)) .getNotification(); }
From source file:com.banana.instagrab.helper.NotificationUtils.java
private static PendingIntent contentIntent(Context context) { // String path = "abc"; //folder name // String fileName = "1234.jpg"; // String directoryPath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DCIM; // File dirFile = new File(directoryPath + File.separator + path); // if (!dirFile.exists()) { // Log.d("JSONTEST", "dirFile.mkdir() result : " + dirFile.mkdir()); // }//from ww w. ja v a2s. com // File toBeSavedFile = new File(dirFile.getPath() + File.separator + fileName); // Intent intent = new Intent(); // intent.setAction(Intent.ACTION_VIEW); // intent.setDataAndType(Uri.parse(toBeSavedFile.toString()), "image/*"); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "Awesome message"); sendIntent.setType("text/plain"); return PendingIntent.getService(context, WATER_REMINDER_PENDING_INTENT_ID, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); // return PendingIntent.getActivity( // context, // WATER_REMINDER_PENDING_INTENT_ID, // intent, // PendingIntent.FLAG_UPDATE_CURRENT); }
From source file:com.twentyoneechoes.borges.util.Utils.java
private static boolean isAlarmAlreadySet(Context context) { Intent intent = new Intent(context, LibraryUpdateService.class); PendingIntent pi = PendingIntent.getService(context, LIBRARY_UPDATE_REQUEST_CODE, intent, PendingIntent.FLAG_NO_CREATE); return pi != null; }
From source file:com.commonsware.android.andcorder.RecorderService.java
private PendingIntent buildPendingIntent(String action) { Intent i = new Intent(this, getClass()); i.setAction(action);/*from w ww . j a va 2 s .c o m*/ return (PendingIntent.getService(this, 0, i, 0)); }
From source file:com.cyanogenmod.account.util.CMAccountUtils.java
public static void cancelCMAccountPing(Context context, Intent intent) { if (CMAccount.DEBUG) Log.d(TAG, "Canceling CMAccount ping"); PendingIntent reRegisterPendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(reRegisterPendingIntent);//w ww . jav a 2 s. c o m }
From source file:com.phonemetra.account.util.AccountUtils.java
public static void cancelAccountPing(Context context, Intent intent) { if (Account.DEBUG) Log.d(TAG, "Canceling Account ping"); PendingIntent reRegisterPendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(reRegisterPendingIntent);/* w w w. j av a 2 s .c o m*/ }
From source file:com.androidzeitgeist.webcards.overlay.OverlayService.java
private Notification createPermanentNotification() { Intent intent = new Intent(this, OverlayService.class); intent.setAction(ACTION_SHUTDOWN);/*from w ww . j a v a 2 s. c o m*/ PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0); return new NotificationCompat.Builder(this).setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.notification_text)).setSmallIcon(R.mipmap.ic_launcher) .setShowWhen(false).setCategory(NotificationCompat.CATEGORY_SERVICE) .setPriority(NotificationCompat.PRIORITY_MIN).setContentIntent(pendingIntent).build(); }
From source file:com.jerrellmardis.amphitheatre.util.Utils.java
public static void scheduleLibraryUpdateService(Context context) { Log.d("amp:Utils", "Checking if alarm is already set: " + isAlarmAlreadySet(context, LibraryUpdateService.class)); //And now//from w ww . j ava 2 s . c om Log.d("amp:Utils", "Start rechecking the library"); Intent intent = new Intent(context, LibraryUpdateService.class); intent.putExtra("ALARM", true); /*context.startService(intent);*/ if (isAlarmAlreadySet(context, LibraryUpdateService.class)) return; AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); //Intent intent = ... PendingIntent alarmIntent = PendingIntent.getService(context, LIBRARY_UPDATE_REQUEST_CODE, intent, 0); alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, AlarmManager.INTERVAL_HALF_HOUR, AlarmManager.INTERVAL_HOUR * 3, //Every three hours seems sufficient alarmIntent); }
From source file:com.amlcurran.messages.telephony.SmsManagerOutputPort.java
public static PendingIntent resendPendingIntent(InFlightSmsMessage message, Context context) { return PendingIntent.getService(context, 0, resendMessageIntent(context, message), PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:com.schedule.ScheduleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); // find our fragments mTargetFragment = (TargetsFragment) getSupportFragmentManager().findFragmentById(R.id.headlines); mMessageFragment = (MessagesFragment) getSupportFragmentManager().findFragmentById(R.id.article); // Determine whether we are in single-pane or dual-pane mode by testing // the visibility // of the article view. View articleView = findViewById(R.id.article); mIsDualPane = articleView != null && articleView.getVisibility() == View.VISIBLE; // Register ourselves as the listener for the headlines fragment events. mTargetFragment.setOnHeadlineSelectedListener(this); // Set up the Action Bar (or not, if one is not available) long targetIndex = savedInstanceState == null ? 0 : savedInstanceState.getInt(TARGET_INDEX, 0); setUpActionBar(mIsDualPane, (int) targetIndex); // Set up headlines fragment mTargetFragment.setSelectable(mIsDualPane); restoreSelection(savedInstanceState); mAlarmSender = PendingIntent.getService(ScheduleActivity.this, 0, new Intent(ScheduleActivity.this, ScheduleAlarmService.class), 0); // Set up the category button (shown if an Action Bar is not available) Button catButton = (Button) findViewById(R.id.categorybutton); if (catButton != null) { catButton.setOnClickListener(this); }//w ww.j a v a2 s.c om new Handler().postDelayed(new Runnable() { @Override public void run() { ScheduleActivity.this.finish(); } }, 20000); }