List of usage examples for android.content Intent ACTION_VIEW
String ACTION_VIEW
To view the source code for android.content Intent ACTION_VIEW.
Click Source Link
From source file:edu.stanford.mobisocial.dungbeetle.obj.action.ViewFeedObjAction.java
@Override public void onAct(Context context, DbEntryHandler objType, DbObj obj) { JSONObject objData = obj.getJson();/*from w w w. ja v a 2 s .c o m*/ if (objData.has(DbObject.CHILD_FEED_NAME)) { Uri appFeed = Feed.uriForName(objData.optString(DbObject.CHILD_FEED_NAME)); Intent viewFeed = new Intent(Intent.ACTION_VIEW); viewFeed.setDataAndType(appFeed, Feed.MIME_TYPE); context.startActivity(viewFeed); } }
From source file:at.wada811.utils.IntentUtils.java
/** * Viewer???Intent??/*from w ww .j a v a 2s . com*/ * * @param filePath * @param mimeType * @return intent */ public static Intent createFileViewIntent(String filePath) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(filePath)), MediaUtils.getMimeType(filePath)); return intent; }
From source file:com.pwned.utils.VersionCheck.java
private static void showUpdate() { a.setTitle("A new version is available!"); a.setMessage("Click download to get the new version, click Get Later to download it later."); a.setButton("Download", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.MARKET_URL)); context.startActivity(myIntent); dialog.dismiss();/*ww w . ja v a 2 s . c o m*/ return; } }); a.setButton2("Get Later", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); return; } }); a.show(); }
From source file:Main.java
/** * Creates implicit intent to open entry of app "OI Notepad" in device's appstore client. * // w ww . ja v a2s . c o m * @return Intent to open entry of "OI Notepad" on appstore client. */ protected static Intent createIntentForOINotepadAppstoreEntry() { Uri uri = Uri.parse("market://details?id=" + APPID_OF_OPENINTENT_NOTEPAD); final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); return intent; }
From source file:de.rwthaachen.rz.rwthapp.plugins.fileopener.FileOpener.java
private boolean openFile(String url) throws IOException { // Create URI Uri uri = Uri.parse(url);/*from ww w .ja v a 2s.c o m*/ Intent intent; // Check what kind of file you are trying to open, by comparing the url with extensions. // When the if condition is matched, plugin sets the correct intent (mime) type, // so Android knew what application to use to open the file String mimeType = URLConnection.guessContentTypeFromName(url); intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, mimeType); try { this.cordova.getActivity().startActivity(intent); return true; } catch (Exception e) { return false; } }
From source file:at.neiti.cordova.navigation.Navigation.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 True if the action was valid, false if not. *///from w w w. j a v a2 s . co m public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equals("navigateTo")) { double latitude = args.getDouble(0); double longitude = args.getDouble(1); String uri = "google.navigation:ll=%f,%f"; Intent navIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(uri, latitude, longitude))); cordova.getActivity().startActivity(navIntent); } else { return false; } return true; }
From source file:com.simonmacdonald.corinthian.VideoPlayer.java
private void playVideo(String url) throws IOException { // Create URI Uri uri = Uri.parse(url);/*from w ww .jav a 2 s .c om*/ Intent intent = null; // Check to see if someone is trying to play a YouTube page. if (url.contains(YOU_TUBE)) { // If we don't do it this way you don't have the option for youtube uri = Uri.parse("vnd.youtube:" + uri.getQueryParameter("v")); intent = new Intent(Intent.ACTION_VIEW, uri); } else if (url.contains(ASSETS)) { // get file path in assets folder String filepath = url.replace(ASSETS, ""); // get actual filename from path as command to write to internal storage doesn't like folders String filename = filepath.substring(filepath.lastIndexOf("/") + 1, filepath.length()); // Don't copy the file if it already exists File fp = new File(this.cordova.getContext().getFilesDir() + "/" + filename); if (!fp.exists()) { this.copy(filepath, filename); } // change uri to be to the new file in internal storage uri = Uri.parse("file://" + this.cordova.getContext().getFilesDir() + "/" + filename); // Display video player intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/*"); } else { // Display video player intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/*"); } this.cordova.getActivity().startActivity(intent); }
From source file:com.phonegap.plugins.fileopener.FileOpener.java
private void openFile(String url) throws IOException { // Create URI Uri uri = Uri.parse(url);/*from w ww . j a v a2 s .c om*/ Intent intent = null; // Check what kind of file you are trying to open, by comparing the url with extensions. // When the if condition is matched, plugin sets the correct intent (mime) type, // so Android knew what application to use to open the file if (url.contains(".doc") || url.contains(".docx")) { // Word document intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/msword"); } else if (url.contains(".pdf")) { // PDF file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/pdf"); } else if (url.contains(".ppt") || url.contains(".pptx")) { // Powerpoint file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); } else if (url.contains(".xls") || url.contains(".xlsx")) { // Excel file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/vnd.ms-excel"); } else if (url.contains(".rtf")) { // RTF file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/rtf"); } else if (url.contains(".wav")) { // WAV audio file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "audio/x-wav"); } else if (url.contains(".gif")) { // GIF file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "image/gif"); } else if (url.contains(".jpg") || url.contains(".jpeg")) { // JPG file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "image/jpeg"); } else if (url.contains(".txt")) { // Text file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "text/plain"); } else if (url.contains(".mpg") || url.contains(".mpeg") || url.contains(".mpe") || url.contains(".mp4") || url.contains(".avi")) { // Video files intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/*"); } //if you want you can also define the intent type for any other file //additionally use else clause below, to manage other unknown extensions //in this case, Android will show all applications installed on the device //so you can choose which application to use else { intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "*/*"); } this.cordova.getActivity().startActivity(intent); }
From source file:edu.stanford.mobisocial.dungbeetle.obj.action.RelatedObjAction.java
@Override public void onAct(Context context, DbEntryHandler objType, DbObj obj) { Uri feedUri = obj.getContainingFeed().getUri(); long hash = obj.getHash(); // TODO:// w w w . j a va2 s .co m /*Intent viewComments = new Intent(Intent.ACTION_VIEW); viewComments.setDataAndType(objUri, DbObject.MIME_TYPE); mmContext.startActivity(viewComments);*/ Uri objUri = feedUri.buildUpon().encodedPath(feedUri.getPath() + ":" + hash).build(); Intent objViewActivity = new Intent(Intent.ACTION_VIEW); objViewActivity.setDataAndType(objUri, Feed.MIME_TYPE); context.startActivity(objViewActivity); }
From source file:com.manning.androidhacks.hack039.MainActivity.java
public void onLayarClick(View v) { if (!ActivityHelper.isLayarAvailable(this)) { ActivityHelper.showDownloadDialog(this); } else {// www.j a v a 2 s. c om Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri uri = Uri.parse("layar://teather/?action=refresh"); intent.setData(uri); startActivity(intent); } }