List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:com.epsi.plugins.cordova.CafeBazaar.java
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { if (action.equals("display-app")) { try {//from w w w .j a v a 2 s . c o m JSONObject arg_object = args.getJSONObject(0); String app = arg_object.getString("app"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("bazaar://details?id=" + app)); intent.setPackage("com.farsitel.bazaar"); this.cordova.getActivity().startActivity(intent); callbackContext.success("success"); return true; } catch (Exception e) { System.err.println("Exception: " + e.getMessage()); callbackContext.error(e.getMessage()); return false; } } if (action.equals("rate-app")) { try { JSONObject arg_object = args.getJSONObject(0); String app = arg_object.getString("app"); Intent intent = new Intent(Intent.ACTION_EDIT); intent.setData(Uri.parse("bazaar://details?id=" + app)); intent.setPackage("com.farsitel.bazaar"); this.cordova.getActivity().startActivity(intent); callbackContext.success("success"); return true; } catch (Exception e) { System.err.println("Exception: " + e.getMessage()); callbackContext.error(e.getMessage()); return false; } } if (action.equals("disp-developer")) { try { JSONObject arg_object = args.getJSONObject(0); String developer = arg_object.getString("developer"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("bazaar://collection?slug=by_author&aid=" + developer)); intent.setPackage("com.farsitel.bazaar"); this.cordova.getActivity().startActivity(intent); callbackContext.success("success"); return true; } catch (Exception e) { System.err.println("Exception: " + e.getMessage()); callbackContext.error(e.getMessage()); return false; } } //callbackContext.error("false command"); return true; }
From source file:com.manning.androidhacks.hack039.MainActivity.java
public void onLayarClick(View v) { if (!ActivityHelper.isLayarAvailable(this)) { ActivityHelper.showDownloadDialog(this); } else {/*from w w w.ja v a 2s . c o m*/ Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri uri = Uri.parse("layar://teather/?action=refresh"); intent.setData(uri); startActivity(intent); } }
From source file:com.guinatal.refreshgallery.PluginRefreshGallery.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. *///from w w w . j a v a 2 s.co m @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { this.callbackContext = callbackContext; try { if (action.equals("refresh")) { String filePath = checkFilePath(args.getString(0)); if (filePath.equals("")) { PluginResult r = new PluginResult(PluginResult.Status.ERROR); callbackContext.sendPluginResult(r); return true; } File file = new File(filePath); Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); scanIntent.setData(Uri.fromFile(file)); Context context = webView.getContext(); context.sendBroadcast(scanIntent); } PluginResult r = new PluginResult(PluginResult.Status.OK); callbackContext.sendPluginResult(r); return true; } catch (JSONException e) { PluginResult r = new PluginResult(PluginResult.Status.JSON_EXCEPTION); callbackContext.sendPluginResult(r); return true; } catch (Exception e) { PluginResult r = new PluginResult(PluginResult.Status.ERROR); callbackContext.sendPluginResult(r); return true; } }
From source file:com.appdynamics.demo.gasp.fragment.TwitterResponderFragment.java
private void setTweets() { TwitterStreamActivity activity = (TwitterStreamActivity) getActivity(); try {// w w w. j a v a 2 s .c o m // Get Twitter search keyword from Shared Preferences SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String keyword = gaspSharedPreferences.getString(getString(R.string.gasp_twitter_preferences), ""); if (mTweets == null) { Intent intent = new Intent(activity, RESTIntentService.class); intent.setData(Uri.parse(TwitterAPI.getTwitterApiSearch())); Bundle params = new Bundle(); params.putString("q", keyword); params.putString("count", "10"); Bundle headers = new Bundle(); headers.putString("Authorization", "Bearer " + TwitterStreamActivity.getTwitterOAuthToken()); intent.putExtra(RESTIntentService.EXTRA_PARAMS, params); intent.putExtra(RESTIntentService.EXTRA_HEADERS, headers); intent.putExtra(RESTIntentService.EXTRA_RESULT_RECEIVER, getResultReceiver()); activity.startService(intent); } else if (activity != null) { ArrayAdapter<String> adapter = activity.getArrayAdapter(); adapter.clear(); for (String tweet : mTweets) { adapter.add(tweet); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.cloudbees.gasp.fragment.TwitterResponderFragment.java
private void setTweets() { TwitterStreamActivity activity = (TwitterStreamActivity) getActivity(); try {//from www .ja v a2 s. co m // Get Twitter search keyword from Shared Preferences SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String keyword = gaspSharedPreferences.getString(getString(R.string.gasp_twitter_preferences), ""); if (mTweets == null && activity != null) { Intent intent = new Intent(activity, RESTIntentService.class); intent.setData(Uri.parse(TwitterAPI.getTwitterApiSearch())); Bundle params = new Bundle(); params.putString("q", keyword); params.putString("count", "10"); Bundle headers = new Bundle(); headers.putString("Authorization", "Bearer " + TwitterStreamActivity.getTwitterOAuthToken()); intent.putExtra(RESTIntentService.EXTRA_PARAMS, params); intent.putExtra(RESTIntentService.EXTRA_HEADERS, headers); intent.putExtra(RESTIntentService.EXTRA_RESULT_RECEIVER, getResultReceiver()); activity.startService(intent); } else if (activity != null) { ArrayAdapter<String> adapter = activity.getArrayAdapter(); adapter.clear(); for (String tweet : mTweets) { adapter.add(tweet); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.arthackday.killerapp.GCMIntentService.java
@Override protected void onMessage(Context ctxt, Intent message) { Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh GCMessage"); Bundle extras = message.getExtras(); /*/*from w w w . j ava 2 s .co m*/ * TO DO! CHANGE WHAT THE MESSAGES DO!! */ for (String key : extras.keySet()) { Log.i(getClass().getSimpleName(), String.format("onMessage: %s=%s", key, extras.getString(key))); if (key.equals(KillerConstants.EXTRA_KEY_AUDIO)) { Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh pushAudio"); Intent i = new Intent(); Log.i("REMOVE BEFORE COMMIT", extras.getString(key)); Bundle bundle = new Bundle(); //Add your data to bundle bundle.putString(KillerConstants.EXTRA_KEY_AUDIO, extras.getString(key)); //Add the bundle to the intent i.putExtras(bundle); i.setClassName("com.arthackday.killerapp", "com.arthackday.killerapp.PushAudio"); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); } if (key.equals(KillerConstants.EXTRA_KEY_PUSHCALL)) { Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh callnumber"); String number = extras.getString(KillerConstants.EXTRA_KEY_PUSHCALL); String uri = "tel:" + number.trim(); Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse(uri)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } }
From source file:com.cloudbees.gasp.fragment.TwitterSearchResponderFragment.java
private void setTweets() { TwitterRESTServiceActivity activity = (TwitterRESTServiceActivity) getActivity(); if (mTweets == null && activity != null) { // This is where we make our REST call to the service. We also pass in our ResultReceiver // defined in the RESTResponderFragment super class. // We will explicitly call our Service since we probably want to keep it as a private // component in our app. You could do this with Intent actions as well, but you have // to make sure you define your intent filters correctly in your manifest. Intent intent = new Intent(activity, RESTService.class); intent.setData(Uri.parse("http://search.twitter.com/search.json")); // Here we are going to place our REST call parameters. Note that // we could have just used Uri.Builder and appendQueryParameter() // here, but I wanted to illustrate how to use the Bundle params. Bundle params = new Bundle(); params.putString("q", "cloudbees"); intent.putExtra(RESTService.EXTRA_PARAMS, params); intent.putExtra(RESTService.EXTRA_RESULT_RECEIVER, getResultReceiver()); // Here we send our Intent to our RESTService. activity.startService(intent);//from ww w.java2 s.com } else if (activity != null) { // Here we check to see if our activity is null or not. // We only want to update our views if our activity exists. ArrayAdapter<String> adapter = activity.getArrayAdapter(); // Load our list adapter with our Tweets. adapter.clear(); for (String tweet : mTweets) { adapter.add(tweet); } } }
From source file:io.github.pwlin.cordova.plugins.fileopener2.FileOpener2.java
private void _uninstall(String packageId, CallbackContext callbackContext) throws JSONException { if (this._appIsInstalled(packageId)) { Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.parse("package:" + packageId)); cordova.getActivity().startActivity(intent); callbackContext.success();/*from ww w .ja va 2 s. c o m*/ } else { JSONObject errorObj = new JSONObject(); errorObj.put("status", PluginResult.Status.ERROR.ordinal()); errorObj.put("message", "This package is not installed"); callbackContext.error(errorObj); } }
From source file:com.ryan.ryanreader.reddit.prepared.RedditPreparedPost.java
public static void onActionMenuItemSelected(final RedditPreparedPost post, final Fragment fragmentParent, final Action action) { final Activity activity = fragmentParent.getSupportActivity(); switch (action) { case UPVOTE://from w w w. ja v a 2 s.c o m post.action(activity, RedditAPI.RedditAction.UPVOTE); break; case DOWNVOTE: post.action(activity, RedditAPI.RedditAction.DOWNVOTE); break; case UNVOTE: post.action(activity, RedditAPI.RedditAction.UNVOTE); break; case SAVE: post.action(activity, RedditAPI.RedditAction.SAVE); break; case UNSAVE: post.action(activity, RedditAPI.RedditAction.UNSAVE); break; case HIDE: post.action(activity, RedditAPI.RedditAction.HIDE); break; case UNHIDE: post.action(activity, RedditAPI.RedditAction.UNHIDE); break; case REPORT: new AlertDialog.Builder(activity).setTitle(R.string.action_report) .setMessage(R.string.action_report_sure) .setPositiveButton(R.string.action_report, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { post.action(activity, RedditAPI.RedditAction.REPORT); // TODO update the view to show the result // TODO don't forget, this also hides } }).setNegativeButton(R.string.dialog_cancel, null).show(); break; case EXTERNAL: { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(post.url)); activity.startActivity(intent); break; } case SELFTEXT_LINKS: { final HashSet<String> linksInComment = LinkHandler .computeAllLinks(StringEscapeUtils.unescapeHtml4(post.src.selftext)); if (linksInComment.isEmpty()) { General.quickToast(activity, R.string.error_toast_no_urls_in_self); } else { final String[] linksArr = linksInComment.toArray(new String[linksInComment.size()]); final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setItems(linksArr, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { LinkHandler.onLinkClicked(activity, linksArr[which], false, post.src); dialog.dismiss(); } }); final AlertDialog alert = builder.create(); alert.setTitle(R.string.action_selftext_links); alert.setCanceledOnTouchOutside(true); alert.show(); } break; } case SAVE_IMAGE: { final RedditAccount anon = RedditAccountManager.getAnon(); CacheManager.getInstance(activity) .makeRequest(new CacheRequest(General.uriFromString(post.imageUrl), anon, null, Constants.Priority.IMAGE_VIEW, 0, CacheRequest.DownloadType.IF_NECESSARY, Constants.FileType.IMAGE, false, false, false, activity) { @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(context, t); } @Override protected void onDownloadNecessary() { General.quickToast(context, R.string.download_downloading); } @Override protected void onDownloadStarted() { } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(context, type, t, status); General.showResultDialog(activity, error); } @Override protected void onProgress(long bytesRead, long totalBytes) { } @Override protected void onSuccess(CacheManager.ReadableCacheFile cacheFile, long timestamp, UUID session, boolean fromCache, String mimetype) { File dst = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), General.uriFromString(post.imageUrl).getPath()); if (dst.exists()) { int count = 0; while (dst.exists()) { count++; dst = new File( Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES), count + "_" + General.uriFromString(post.imageUrl).getPath().substring(1)); } } try { General.copyFile(cacheFile.getInputStream(), dst); } catch (IOException e) { notifyFailure(RequestFailureType.STORAGE, e, null, "Could not copy file"); return; } activity.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + dst.getAbsolutePath()))); General.quickToast(context, context.getString(R.string.action_save_image_success) + " " + dst.getAbsolutePath()); } }); break; } case SHARE: { final Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("text/plain"); mailer.putExtra(Intent.EXTRA_SUBJECT, post.title); mailer.putExtra(Intent.EXTRA_TEXT, post.url); activity.startActivity(Intent.createChooser(mailer, activity.getString(R.string.action_share))); break; } case SHARE_COMMENTS: { final Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("text/plain"); mailer.putExtra(Intent.EXTRA_SUBJECT, "Comments for " + post.title); mailer.putExtra(Intent.EXTRA_TEXT, Constants.Reddit.getUri(Constants.Reddit.PATH_COMMENTS + post.idAlone).toString()); activity.startActivity( Intent.createChooser(mailer, activity.getString(R.string.action_share_comments))); break; } case COPY: { ClipboardManager manager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); manager.setText(post.url); break; } case GOTO_SUBREDDIT: { final RedditSubreddit subreddit = new RedditSubreddit("/r/" + post.src.subreddit, "/r/" + post.src.subreddit, true); final Intent intent = new Intent(activity, PostListingActivity.class); intent.putExtra("subreddit", subreddit); activity.startActivityForResult(intent, 1); break; } case USER_PROFILE: UserProfileDialog.newInstance(post.src.author).show(activity); break; case PROPERTIES: PostPropertiesDialog.newInstance(post.src).show(activity); break; case COMMENTS: ((RedditPostView.PostSelectionListener) fragmentParent).onPostCommentsSelected(post); break; case LINK: ((RedditPostView.PostSelectionListener) fragmentParent).onPostSelected(post); break; case COMMENTS_SWITCH: if (!(activity instanceof MainActivity)) activity.finish(); ((RedditPostView.PostSelectionListener) fragmentParent).onPostCommentsSelected(post); break; case LINK_SWITCH: if (!(activity instanceof MainActivity)) activity.finish(); ((RedditPostView.PostSelectionListener) fragmentParent).onPostSelected(post); break; case ACTION_MENU: showActionMenu(activity, fragmentParent, post); break; case REPLY: final Intent intent = new Intent(activity, CommentReplyActivity.class); intent.putExtra("parentIdAndType", post.idAndType); activity.startActivity(intent); break; } }
From source file:com.fastbootmobile.rssdemo.PushReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "ACTION : " + intent.getAction()); // Debug log the intent "action" // Get the shared preferences for OwnPush keys SharedPreferences pref = context.getApplicationContext().getSharedPreferences(OwnPushClient.PREF_PUSH, Context.MODE_PRIVATE); if (intent.getAction().equals(OwnPushClient.INTENT_RECEIVE)) { // This is a push message Log.d(TAG, "Decrypt : " + intent.getExtras().getString(OwnPushClient.EXTRA_DATA)); OwnPushCrypto fp = new OwnPushCrypto(); // Create a crypto object for decrypt // Get the app key pair from shared preferences (these have been confirmed by the register intent) OwnPushCrypto.AppKeyPair keys = fp.getKey(pref.getString(OwnPushClient.PREF_PUBLIC_KEY, ""), pref.getString(OwnPushClient.PREF_PRIVATE_KEY, "")); // Decrypt the message from the intent extra data String msg = fp.decryptFromIntent(intent.getExtras(), BuildConfig.APP_PUBLIC_KEY, keys); JSONObject jObj;//from w w w .j ava2s .c om if (msg != null) { Log.e(TAG, "RSS : " + msg); try { // Decode the JOSN data in the message jObj = new JSONObject(msg); Intent i = new Intent(Intent.ACTION_VIEW); // Create the intent i.setData(Uri.parse(jObj.getString("link"))); // Set the data using URI (these are web links) // Convert to pending intent PendingIntent pIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), i, 0); // Create the notification Notification n = new Notification.Builder(context.getApplicationContext()) .setContentTitle("OwnPush RSS") // Main Title .setContentText(jObj.getString("title")) // Set content .setContentIntent(pIntent) // Add the pending intent .setSmallIcon(R.drawable.ic_done).setAutoCancel(true) // Remove notification if opened .build(); n.defaults |= Notification.DEFAULT_SOUND; // Make some noise on push // Get the notification manager and display notification NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notification_num, n); // Increase the notification counter by 1 notification_num++; } catch (Exception e) { return; } } } }