List of usage examples for android.app PendingIntent getActivity
public static PendingIntent getActivity(Context context, int requestCode, Intent intent, @Flags int flags)
From source file:org.zirco.ui.activities.MainActivity.java
/** * Restart the application./*from w w w . j ava 2 s.c om*/ */ public void restartApplication() { PendingIntent intent = PendingIntent.getActivity(this.getBaseContext(), 0, new Intent(getIntent()), getIntent().getFlags()); AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 2000, intent); System.exit(2); }
From source file:com.gsoc.ijosa.liquidgalaxycontroller.PW.UrlDeviceDiscoveryService.java
private PendingIntent createReturnToAppPendingIntent() { Intent intent = new Intent(this, LGPCAdminActivity.class); int requestID = (int) System.currentTimeMillis(); PendingIntent pendingIntent = PendingIntent.getActivity(this, requestID, intent, 0); return pendingIntent; }
From source file:at.alladin.rmbt.android.test.RMBTLoopService.java
private void setFinishedNotification() { Intent notificationIntent = new Intent(getApplicationContext(), RMBTMainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent openAppIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0); final Resources res = getResources(); final Notification notification = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.stat_icon_loop) .setContentTitle(res.getText(R.string.loop_notification_finished_title)) .setTicker(res.getText(R.string.loop_notification_finished_ticker)).setContentIntent(openAppIntent) .build();// w ww . j a va2 s .c o m //notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(NotificationIDs.LOOP_ACTIVE, notification); }
From source file:com.autoupdateapk.AutoUpdateApk.java
protected void raise_notification() { String ns = Context.NOTIFICATION_SERVICE; NotificationManager nm = (NotificationManager) context.getSystemService(ns); // nm.cancel( NOTIFICATION_ID ); // tried this, but it just doesn't do // the trick =( nm.cancelAll();/* w w w . j a va 2 s . c o m*/ String update_file = preferences.getString(UPDATE_FILE, ""); if (update_file.length() > 0) { setChanged(); notifyObservers(AUTOUPDATE_HAVE_UPDATE); // raise notification Notification notification = new Notification(appIcon, appName + " update", System.currentTimeMillis()); notification.flags |= NOTIFICATION_FLAGS; CharSequence contentTitle = appName + " update available"; CharSequence contentText = "Select to install"; Intent notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.setDataAndType( Uri.parse("file://" + context.getFilesDir().getAbsolutePath() + "/" + update_file), ANDROID_PACKAGE); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); nm.notify(NOTIFICATION_ID, notification); } else { nm.cancel(NOTIFICATION_ID); } }
From source file:android.app.Notification.java
/** * @hide//from w w w. j a v a2 s .c o m */ public Notification(Context context, int icon, CharSequence tickerText, long when, CharSequence contentTitle, CharSequence contentText, Intent contentIntent) { this.when = when; this.icon = icon; this.tickerText = tickerText; setLatestEventInfo(context, contentTitle, contentText, PendingIntent.getActivity(context, 0, contentIntent, 0)); }
From source file:com.piusvelte.taplock.client.core.TapLockService.java
private void buildWidget(int appWidgetId) { RemoteViews rv = new RemoteViews(getPackageName(), R.layout.widget); String deviceName = null;/*from www . j a va 2 s . c o m*/ for (JSONObject deviceJObj : mDevices) { if (deviceJObj.has(KEY_WIDGETS) && deviceJObj.has(KEY_NAME)) { JSONArray widgetsJArr = null; try { widgetsJArr = deviceJObj.getJSONArray(KEY_WIDGETS); } catch (JSONException e) { e.printStackTrace(); } if (widgetsJArr != null) { for (int i = 0, l = widgetsJArr.length(); (i < l) && (deviceName == null); i++) { int widgetId; try { widgetId = widgetsJArr.getInt(i); } catch (JSONException e) { widgetId = AppWidgetManager.INVALID_APPWIDGET_ID; e.printStackTrace(); } if ((widgetId != AppWidgetManager.INVALID_APPWIDGET_ID) && (appWidgetId == widgetId)) { try { deviceName = deviceJObj.getString(KEY_NAME); } catch (JSONException e) { e.printStackTrace(); } break; } } } if (deviceName != null) break; } } if (deviceName == null) deviceName = "unknown"; rv.setTextViewText(R.id.device_name, deviceName); rv.setOnClickPendingIntent(R.id.widget_icon, PendingIntent.getActivity(this, 0, TapLock.getPackageIntent(this, TapLockToggle.class) .setData(Uri.parse(String.format(getString(R.string.device_uri), deviceName))), Intent.FLAG_ACTIVITY_NEW_TASK)); AppWidgetManager.getInstance(this).updateAppWidget(appWidgetId, rv); }
From source file:it.feio.android.omninotes.async.DataBackupIntentService.java
/** * Creation of notification on operations completed *///from w w w .j a va 2 s .c o m private void createNotification(Intent intent, Context mContext, String title, String message, File backupDir) { // The behavior differs depending on intent action Intent intentLaunch; if (DataBackupIntentService.ACTION_DATA_IMPORT.equals(intent.getAction()) || DataBackupIntentService.ACTION_DATA_IMPORT_SPRINGPAD.equals(intent.getAction())) { intentLaunch = new Intent(mContext, MainActivity.class); intentLaunch.setAction(Constants.ACTION_RESTART_APP); } else { intentLaunch = new Intent(); } // Add this bundle to the intent intentLaunch.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentLaunch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Creates the PendingIntent PendingIntent notifyIntent = PendingIntent.getActivity(mContext, 0, intentLaunch, PendingIntent.FLAG_UPDATE_CURRENT); NotificationsHelper mNotificationsHelper = new NotificationsHelper(mContext); mNotificationsHelper.createNotification(R.drawable.ic_content_save_white_24dp, title, notifyIntent) .setMessage(message).setRingtone(prefs.getString("settings_notification_ringtone", null)) .setLedActive(); if (prefs.getBoolean("settings_notification_vibration", true)) mNotificationsHelper.setVibration(); mNotificationsHelper.show(); }
From source file:at.vcity.androidimsocket.services.IMService.java
public void receiveFriendReq(Object... args) { try {//from w w w.j ava 2 s .co m JSONObject params = new JSONObject(args[0].toString()); JSONArray friendarray = params.getJSONArray(FriendInfo.FRIEND_LIST); ArrayList<FriendInfo> unapprovedfriends = new ArrayList<FriendInfo>(); for (int i = 0; i < friendarray.length(); i++) { JSONObject friend = friendarray.getJSONObject(i); FriendInfo f = new FriendInfo(); f.userId = friend.getString(FriendInfo.USER_ID); f.userName = friend.getString(FriendInfo.USERNAME); unapprovedfriends.add(f); } FriendController.setUnapprovedFriendsInfo(unapprovedfriends); String title = "AndroidIM: You got friend request(s)! "; NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.stat_sample).setContentTitle(title).setAutoCancel(true); //.setContentText(text); Intent i = new Intent(this, UnApprovedFriendList.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); // Set the info for the views that show in the notification panel. // msg.length()>15 ? MSG : msg.substring(0, 15); mBuilder.setContentIntent(contentIntent); //TODO: it can be improved, for instance message coming from same user may be concatenated // next version // Send the notification. // We use a layout id because it is a unique number. We use it later to cancel. mNM.notify(R.string.new_friend_request_exist, mBuilder.build()); } catch (JSONException e) { } }
From source file:com.dycody.android.idealnote.async.DataBackupIntentService.java
/** * Creation of notification on operations completed *///www. ja va2 s. c o m private void createNotification(Intent intent, Context mContext, String title, String message, File backupDir) { // The behavior differs depending on intent action Intent intentLaunch; if (DataBackupIntentService.ACTION_DATA_IMPORT.equals(intent.getAction()) || DataBackupIntentService.ACTION_DATA_IMPORT_SPRINGPAD.equals(intent.getAction())) { intentLaunch = new Intent(mContext, MainActivity.class); intentLaunch.setAction(Constants.ACTION_RESTART_APP); } else { intentLaunch = new Intent(); } // Add this bundle to the intent intentLaunch.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentLaunch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Creates the PendingIntent PendingIntent notifyIntent = PendingIntent.getActivity(mContext, 0, intentLaunch, PendingIntent.FLAG_UPDATE_CURRENT); NotificationsHelper mNotificationsHelper = new NotificationsHelper(mContext); mNotificationsHelper .createNotification(com.dycody.android.idealnote.R.drawable.ic_content_save_white_24dp, title, notifyIntent) .setMessage(message).setRingtone(prefs.getString("settings_notification_ringtone", null)) .setLedActive(); if (prefs.getBoolean("settings_notification_vibration", true)) mNotificationsHelper.setVibration(); mNotificationsHelper.show(); }
From source file:arun.com.chromer.browsing.customtabs.CustomTabs.java
private void prepareOpenWith() { final Intent openWithActivity = new Intent(activity, OpenIntentWithActivity.class); openWithActivity.putExtra(EXTRA_KEY_ORIGINAL_URL, url); final PendingIntent openWithActivityPending = PendingIntent.getActivity(activity, 0, openWithActivity, FLAG_UPDATE_CURRENT);//from w ww. j a v a2s . com builder.addMenuItem(activity.getString(R.string.open_with), openWithActivityPending); }