List of usage examples for android.content Intent setAction
public @NonNull Intent setAction(@Nullable String action)
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_communicator.util.FileUtils.java
public static Bitmap entityToBitmap(Context context, HttpEntity entity, final String contentId, boolean withProgressBar, Long contentSize) { try {//from ww w.jav a2 s. c om File file = new File(getDir(), contentId); file.createNewFile(); InputStream is = entity.getContent(); /* * Read bytes to the Buffer until there is nothing more to read(-1) * and write on the fly in the file. */ final FileOutputStream fos = new FileOutputStream(file); final int BUFFER_SIZE = 23 * 1024; BufferedInputStream bis = new BufferedInputStream(is, BUFFER_SIZE); byte[] baf = new byte[BUFFER_SIZE]; int actual = 0; long total = 0; int totalpercent = 0; int auxtotal = 0; while (actual != -1) { fos.write(baf, 0, actual); actual = bis.read(baf, 0, BUFFER_SIZE); if (withProgressBar) { try { total = total + actual; auxtotal = (int) (((total * 100) / contentSize)) / 10; if ((totalpercent != auxtotal) && (totalpercent != 10)) { totalpercent = auxtotal; Intent intent = new Intent(); intent.setAction(ConstantKeys.BROADCAST_DIALOG_PROGRESSBAR); intent.putExtra(ConstantKeys.TOTAL, totalpercent * 10); intent.putExtra(ConstantKeys.LOCALID, contentId.replace(ConstantKeys.EXTENSION_3GP, ConstantKeys.STRING_DEFAULT) .replace(ConstantKeys.EXTENSION_JPG, ConstantKeys.STRING_DEFAULT)); context.sendBroadcast(intent); } } catch (Exception e) { log.error("Error tryng to send broadcast to progressbar", e); } } } fos.close(); if (contentId.contains(ConstantKeys.EXTENSION_JPG)) { return decodeSampledBitmapFromPath(file.getAbsolutePath(), 200, 200); } else { return ThumbnailUtils.createVideoThumbnail(file.getAbsolutePath(), MediaStore.Images.Thumbnails.MINI_KIND); } } catch (Exception e) { new File(getDir(), contentId).delete(); return null; } }
From source file:free.yhc.netmbuddy.utils.Utils.java
public static void resumeApp() { Intent intent = new Intent(Utils.getAppContext(), YTMPActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Utils.getAppContext().startActivity(intent); }
From source file:com.wbtech.ums.UmsAgent.java
private static void postClientDatas(Context context) { if (isFirst) { Intent intent = new Intent(); intent.setAction("cobub.razor.message"); intent.putExtra("deviceid", CommonUtil.getDeviceID(context)); context.sendBroadcast(intent);/*from www . java2s. c om*/ JSONObject clientData = getClientDataJSONObject(context); if (1 == CommonUtil.getReportPolicyMode(context) & CommonUtil.isNetworkAvailable(context)) { MyMessage message = NetworkUitlity.post(UmsConstants.preUrl + UmsConstants.clientDataUrl, clientData.toString()); if (!message.isFlag()) { saveInfoToFile("clientData", clientData, context); CommonUtil.printLog("Errorinfo", message.getMsg()); } } else { saveInfoToFile("clientData", clientData, context); } isFirst = false; } }
From source file:com.codeskraps.lolo.misc.Utils.java
public static PendingIntent getOnTouchIntent(Context context) { PendingIntent pendingIntent = null;/*from w w w .j a v a 2s.c om*/ Intent intent = null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int onClick = Integer.parseInt(prefs.getString(Constants.ONCLICK, "0")); switch (onClick) { case 0: intent = new Intent("com.codeskraps.lol.DO_NOTHING"); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 1: intent = new Intent(context, TweetsFeedActivity.class); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 2: intent = new Intent(); intent.setAction(Constants.BROADCAST_RECEIVER); pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 3: intent = new Intent(context, PrefsActivity.class); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 4: intent = new Intent(Intent.ACTION_VIEW); String url = prefs.getString(Constants.EURL, context.getString(R.string.prefsURL_default)); if (!url.startsWith("http://")) url = "http://" + url; intent.setData(Uri.parse(url)); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; } return pendingIntent; }
From source file:com.onesignal.GenerateNotification.java
private static void addNotificationActionButtons(JSONObject gcmBundle, NotificationCompat.Builder mBuilder, int notificationId, String groupSummary) { try {// w ww . ja v a2 s. co m JSONObject customJson = new JSONObject(gcmBundle.getString("custom")); if (customJson.has("a")) { JSONObject additionalDataJSON = customJson.getJSONObject("a"); if (additionalDataJSON.has("actionButtons")) { JSONArray buttons = additionalDataJSON.getJSONArray("actionButtons"); for (int i = 0; i < buttons.length(); i++) { JSONObject button = buttons.getJSONObject(i); additionalDataJSON.put("actionSelected", button.getString("id")); JSONObject bundle = new JSONObject(gcmBundle.toString()); bundle.put("custom", customJson.toString()); Intent buttonIntent = getNewBaseIntent(notificationId); buttonIntent.setAction("" + i); // Required to keep each action button from replacing extras of each other buttonIntent.putExtra("action_button", true); buttonIntent.putExtra("onesignal_data", bundle.toString()); if (groupSummary != null) buttonIntent.putExtra("summary", groupSummary); else if (gcmBundle.has("grp")) buttonIntent.putExtra("grp", gcmBundle.getString("grp")); PendingIntent buttonPIntent = getNewActionPendingIntent(notificationId, buttonIntent); int buttonIcon = 0; if (button.has("icon")) buttonIcon = getResourceIcon(button.getString("icon")); mBuilder.addAction(buttonIcon, button.getString("text"), buttonPIntent); } } } } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.silentcircle.silenttext.util.DeviceUtils.java
public static Intent getShareDebugInformationIntent(Context context) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", context.getString(R.string.support_email_address), null)); intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.support_email_subject)); intent.putExtra(Intent.EXTRA_TEXT, wrap(LABEL_DEBUG_INFO, getDebugInformation(context))); ResolveInfo info = context.getPackageManager().resolveActivity(intent, 0); if (info == null) { intent.setAction(Intent.ACTION_SEND); intent.setDataAndType(null, "text/plain"); }//from www . ja va2 s. c om return Intent.createChooser(intent, context.getString(R.string.share_with, context.getString(R.string.feedback))); }
From source file:com.farmerbb.secondscreen.util.U.java
public static void listProfilesBroadcast(Context context) { Intent listProfilesIntent = new Intent(); listProfilesIntent.setAction(U.LIST_PROFILES); context.sendBroadcast(listProfilesIntent); }
From source file:MainActivity.java
public void createShortcut(View view) { Intent shortcutIntent = new Intent(this, MainActivity.class); shortcutIntent.setAction(Intent.ACTION_MAIN); Intent installIntent = new Intent(); installIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); installIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)); installIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher)); installIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(installIntent);//from w w w . j a v a2 s.co m }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToWebSessionObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String arg = obj.optString(ARG); Intent launch = new Intent(); launch.setAction(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra("android.intent.extra.APPLICATION_ARGUMENT", arg); launch.putExtra("creator", false); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); String webUrl = obj.optString(WEB_URL); launch.setData(Uri.parse(webUrl));/*from w w w.j a va2 s .c om*/ PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("New Invitation", "Invitation received", "Click to launch application.", contentIntent); }
From source file:com.George.iexpense.activity.Echo.java
private PluginResult openFile(String fileUrl) { Log.d("FileViewerPlugin", "View file" + fileUrl); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); File file = new File(fileUrl); String extension = fileUrl.substring(fileUrl.lastIndexOf(".") + 1); String type = ""; if (extension.toLowerCase().equals("pdf")) { type = "application/pdf"; } else if (extension.toLowerCase().equals("flv")) { type = "video/flv"; } else if (extension.toLowerCase().equals("mp4")) { type = "video/mp4"; } else if (extension.toLowerCase().equals("jpg")) { type = "image/jpg"; }// ww w . ja v a 2s. com intent.setDataAndType(Uri.fromFile(file), type); cordova.getActivity().startActivity(intent); Log.d("FileViewerPlugin", "View complete in" + fileUrl); return new PluginResult(PluginResult.Status.OK, fileUrl); }