List of usage examples for android.content Intent putParcelableArrayListExtra
public @NonNull Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value)
From source file:com.keylesspalace.tusky.ViewMediaActivity.java
public static Intent newIntent(Context context, List<AttachmentViewData> attachments, int index) { final Intent intent = new Intent(context, ViewMediaActivity.class); intent.putParcelableArrayListExtra(EXTRA_ATTACHMENTS, new ArrayList<>(attachments)); intent.putExtra(EXTRA_ATTACHMENT_INDEX, index); return intent; }
From source file:Main.java
@NonNull public static Intent sendEmail(@NonNull String[] to, @NonNull String subject, @NonNull String body, @Nullable List<Uri> attachments) { final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, body); if (attachments != null && !attachments.isEmpty()) { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments)); }/*from w w w .j a va 2 s . c o m*/ return intent; }
From source file:com.geomoby.geodeals.DemoService.java
/** * Issues a notification to inform the user that server has sent a message. *///ww w . j ava 2 s . co m private static void generateNotification(Context context, String message) { if (message.length() > 0) { // Parse the GeoMoby message using the GeoMessage class try { Gson gson = new Gson(); JsonParser parser = new JsonParser(); JsonArray Jarray = parser.parse(message).getAsJsonArray(); ArrayList<GeoMessage> alerts = new ArrayList<GeoMessage>(); for (JsonElement obj : Jarray) { GeoMessage gName = gson.fromJson(obj, GeoMessage.class); alerts.add(gName); } // Prepare Notification and pass the GeoMessage to an Extra NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Intent i = new Intent(context, CustomNotification.class); i.putParcelableArrayListExtra("GeoMessage", (ArrayList<GeoMessage>) alerts); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); // Read from the /assets directory Resources resources = context.getResources(); AssetManager assetManager = resources.getAssets(); try { InputStream inputStream = assetManager.open("geomoby.properties"); Properties properties = new Properties(); properties.load(inputStream); String push_icon = properties.getProperty("push_icon"); int icon = resources.getIdentifier(push_icon, "drawable", context.getPackageName()); int not_title = resources.getIdentifier("notification_title", "string", context.getPackageName()); int not_text = resources.getIdentifier("notification_text", "string", context.getPackageName()); int not_ticker = resources.getIdentifier("notification_ticker", "string", context.getPackageName()); // Manage notifications differently according to Android version if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(icon).setContentTitle(context.getResources().getText(not_title)) .setContentText(context.getResources().getText(not_text)) .setTicker(context.getResources().getText(not_ticker)) .setContentIntent(pendingIntent).setAutoCancel(true); builder.setDefaults(Notification.DEFAULT_ALL); //Vibrate, Sound and Led // Because the ID remains unchanged, the existing notification is updated. notificationManager.notify(notifyID, builder.build()); } else { Notification notification = new Notification(icon, context.getResources().getText(not_text), System.currentTimeMillis()); //Setting Notification Flags notification.defaults |= Notification.DEFAULT_ALL; notification.flags |= Notification.FLAG_AUTO_CANCEL; //Set the Notification Info notification.setLatestEventInfo(context, context.getResources().getText(not_text), context.getResources().getText(not_ticker), pendingIntent); //Send the notification // Because the ID remains unchanged, the existing notification is updated. notificationManager.notify(notifyID, notification); } } catch (IOException e) { System.err.println("Failed to open geomoby property file"); e.printStackTrace(); } } catch (JsonParseException e) { Log.i(TAG, "This is not a GeoMoby notification"); throw new RuntimeException(e); } } }
From source file:gc.david.dfm.ui.activity.ShowInfoActivity.java
public static void open(final Activity activity, final List<LatLng> coordinates, final String distanceAsText) { final Intent openShowInfoActivityIntent = new Intent(activity, ShowInfoActivity.class); openShowInfoActivityIntent.putParcelableArrayListExtra(POSITIONS_LIST_EXTRA_KEY, new ArrayList<Parcelable>(coordinates)); openShowInfoActivityIntent.putExtra(DISTANCE_EXTRA_KEY, distanceAsText); activity.startActivity(openShowInfoActivityIntent); }
From source file:com.hxqc.aroundservice.util.ActivitySwitchAround.java
/** * ?//from w w w.j a va2 s . c om **/ public static void toPositionActivity(Context context, ArrayList<CityList> cityLists, int requestCode, String position) { Intent intent = new Intent(context, PositionActivity.class); intent.putExtra("position", position); intent.putParcelableArrayListExtra(PositionActivity.DATA, cityLists); ((Activity) context).startActivityForResult(intent, requestCode); }
From source file:Main.java
@NonNull public static Intent sendEmail(@NonNull String[] to, @NonNull String subject, @NonNull String body, @Nullable List<Uri> attachments) { final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_SUBJECT, subject); final ArrayList<CharSequence> extraText = new ArrayList<>(1); extraText.add(body);/*from w ww. jav a 2 s. c om*/ intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, extraText); if (attachments != null && !attachments.isEmpty()) { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments)); } return intent; }
From source file:Main.java
/** * Send an email via available mail activity * /* www. j ava 2s. c om*/ * @param context the app context * @param to the email address send to * @param subject the email subject * @param body the email body * @param attachments the uris for attachments */ public static void sendEmail(Context context, String to, String subject, String body, Uri... attachments) { Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); emailIntent.setType("plain/text"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); if (attachments != null && attachments.length != 0) { ArrayList<Uri> uris = new ArrayList<Uri>(); for (int i = 0; i < attachments.length; i++) uris.add(attachments[i]); emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } context.startActivity(Intent.createChooser(emailIntent, null)); }
From source file:Main.java
public static Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType);//from www.j av a 2 s . co m if (attachments.length > 1) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); final ArrayList<CharSequence> textExtra = new ArrayList<>(); textExtra.add(text); intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, textExtra); final ArrayList<Parcelable> uris = new ArrayList<>(); Collections.addAll(uris, attachments); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_STREAM, attachments[0]); } return intent; }
From source file:Main.java
public static Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType);/*from w w w . ja v a 2 s . c om*/ if (attachments.length > 1) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); final ArrayList<CharSequence> textExtra = new ArrayList<>(); textExtra.add(text); intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, textExtra); final ArrayList<Parcelable> uris = new ArrayList<>(); Collections.addAll(uris, attachments); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, text); if (attachments.length > 0) { intent.putExtra(Intent.EXTRA_STREAM, attachments[0]); } } return intent; }
From source file:com.krayzk9s.imgurholo.tools.ImageUtils.java
public static void downloadImage(Fragment fragment, JSONParcelable imageData) { Intent serviceIntent = new Intent(fragment.getActivity(), DownloadService.class); ArrayList<Parcelable> downloadIDs = new ArrayList<Parcelable>(); downloadIDs.add(imageData);//from w w w.ja va2 s . c o m serviceIntent.putParcelableArrayListExtra("ids", downloadIDs); fragment.getActivity().startService(serviceIntent); }