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:com.midisheetmusic.ChooseSongActivity.java
public void doOpenFile(FileUri file) { byte[] data = file.getData(this); if (data == null || data.length <= 6 || !MidiFile.hasMidiHeader(data)) { ChooseSongActivity.showErrorDialog("Error: Unable to open song: " + file.toString(), this); return;/* w ww. jav a 2 s. c o m*/ } updateRecentFile(file); Intent intent = new Intent(Intent.ACTION_VIEW, file.getUri(), this, SheetMusicActivity.class); intent.putExtra(SheetMusicActivity.MidiTitleID, file.toString()); startActivity(intent); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToGroupObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { try {/*from w ww . java 2 s . c om*/ String groupName = obj.getString(GROUP_NAME); Uri dynUpdateUri = Uri.parse(obj.getString(DYN_UPDATE_URI)); Intent launch = new Intent(Intent.ACTION_VIEW); launch.setData(dynUpdateUri); launch.putExtra("type", TYPE); launch.putExtra("creator", false); launch.putExtra(SENDER, from.id); launch.putExtra(GROUP_NAME, groupName); launch.putExtra(DYN_UPDATE_URI, dynUpdateUri); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("Invitation from " + from.name, "Invitation from " + from.name, "Join the group '" + groupName + "'.", contentIntent); } catch (JSONException e) { Log.e(TAG, "Error handling message: ", e); } }
From source file:com.appnexus.opensdk.ANJAMImplementation.java
private static void callMayDeepLink(WebView webView, Uri uri) { boolean mayDeepLink; String cb = uri.getQueryParameter("cb"); String urlParam = uri.getQueryParameter("url"); if ((webView.getContext() == null) || (webView.getContext().getPackageManager() == null) || (urlParam == null)) {/*from ww w.j a v a2s .c o m*/ mayDeepLink = false; } else { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(urlParam))); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mayDeepLink = intent.resolveActivity(webView.getContext().getPackageManager()) != null; } LinkedList<BasicNameValuePair> list = new LinkedList<BasicNameValuePair>(); list.add(new BasicNameValuePair(KEY_CALLER, CALL_MAYDEEPLINK)); list.add(new BasicNameValuePair("mayDeepLink", String.valueOf(mayDeepLink))); loadResult(webView, cb, list); }
From source file:com.memetro.android.alerts.ThermometerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mActivity.fullActionBar();/* w w w . j a v a 2 s .c om*/ View inflated = inflater.inflate(R.layout.fragment_thermometer, container, false); // Crowdfunding inflated.findViewById(R.id.crowdfunding).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://goteo.org/project/memetro-app/home")); startActivity(browserIntent); } }); alertListView = (PullToRefreshListView) inflated.findViewById(R.id.alertListView); noAlerts = (LinearLayout) inflated.findViewById(R.id.no_alerts); alertListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() { @Override public void onRefresh(PullToRefreshBase<ListView> refreshView) { getAlerts(); } }); setList(); getAlerts(); alertListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { try { Alert alert = alerts.get(i - 1); CommentDialog.showDialog(mActivity, alert.description, alert.username, (alert.username.equals(userData.username)), alert.alertId); } catch (Exception e) { e.printStackTrace(); } } }); return inflated; }
From source file:com.grouptuity.venmo.VenmoSDK.java
public static Intent openVenmoPayment(String myAppId, String myAppName, String recipients, String amount, String note, String txn) { String venmo_uri = "venmosdk://paycharge?txn=" + txn; if (!recipients.equals("")) { try {/*www . j a v a 2 s .co m*/ venmo_uri += "&recipients=" + URLEncoder.encode(recipients, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.e("venmodemo", "cannot encode recipients"); } } if (!amount.equals("")) { try { venmo_uri += "&amount=" + URLEncoder.encode(amount, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.e("venmodemo", "cannot encode amount"); } } if (!note.equals("")) { try { venmo_uri += "¬e=" + URLEncoder.encode(note, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.e("venmodemo", "cannot encode note"); } } try { venmo_uri += "&app_id=" + URLEncoder.encode(myAppId, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.e("venmodemo", "cannot encode app ID"); } try { venmo_uri += "&app_name=" + URLEncoder.encode(myAppName, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.e("venmodemo", "cannot encode app Name"); } try { venmo_uri += "&app_local_id=" + URLEncoder.encode("abcd", "UTF-8"); } catch (UnsupportedEncodingException e) { Log.e("venmodemo", "cannot encode app local id"); } venmo_uri += "&using_new_sdk=true"; venmo_uri = venmo_uri.replaceAll("\\+", "%20"); // use %20 encoding instead of + return new Intent(Intent.ACTION_VIEW, Uri.parse(venmo_uri)); }
From source file:com.phonegap.plugins.videoplayer.VideoPlayer.java
private void playVideo(String url) throws IOException { if (url.contains("bit.ly/") || url.contains("goo.gl/") || url.contains("tinyurl.com/") || url.contains("youtu.be/")) { //support for google / bitly / tinyurl / youtube shortens URLConnection con = new URL(url).openConnection(); con.connect();//from w ww .ja v a 2s .c om InputStream is = con.getInputStream(); //new redirected url url = con.getURL().toString(); is.close(); } // Create URI Uri uri = Uri.parse(url); 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")); if (isYouTubeInstalled()) { intent = new Intent(Intent.ACTION_VIEW, uri); } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.google.android.youtube")); } } 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.getActivity().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.getActivity().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.afreire.plugins.video.VideoPlayer.java
private void playVideo(String url) throws IOException { if (url.contains("bit.ly/") || url.contains("goo.gl/") || url.contains("tinyurl.com/") || url.contains("youtu.be/")) { //support for google / bitly / tinyurl / youtube shortens URLConnection con = new URL(url).openConnection(); con.connect();// www .j a v a 2s . c om InputStream is = con.getInputStream(); //new redirected url url = con.getURL().toString(); is.close(); } // Create URI Uri uri = Uri.parse(url); 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")); if (isYouTubeInstalled()) { intent = new Intent(Intent.ACTION_VIEW, uri); } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.google.android.youtube")); } } else if (url.contains(ASSETS)) { // get file path in assets folder String filepath = url.replace(ASSETS, ""); //Remove the path to the file from any location if (filepath.contains("www/file:")) { filepath = filepath.replace("www/file://", ""); } // 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.getActivity().getFilesDir() + "/" + filename); //It uses a fixed name to optimize memory space File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + VIDEO_FILE_NAME); //Always copy the file //if (!fp.exists()) { this.copy(filepath, filename); //} // change uri to be to the new file in internal storage uri = Uri.parse("file://" + this.cordova.getActivity().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.cordova.plugins.startapp.StartApp.java
/** * Starts an activity./* w w w . jav a 2 s . co m*/ * * @param component * Activity ComponentName. * E.g.: com.mycompany.myapp/com.mycompany.myapp.MyActivity */ void startActivity(String component) { try { Intent intent = new Intent("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); intent.setComponent(ComponentName.unflattenFromString(component)); ((DroidGap) this.cordova.getActivity()).startActivity(intent); } catch (ActivityNotFoundException ex) { /** * If not installed, open market */ String[] packageNameSplt = component.split("/"); String packageName = packageNameSplt[0]; Intent marketIntent = new Intent(Intent.ACTION_VIEW); marketIntent.setData(Uri.parse("market://details?id=" + packageName)); ((DroidGap) this.cordova.getActivity()).startActivity(marketIntent); } }
From source file:com.miz.functions.TmdbTrailerSearch.java
@Override protected void onPostExecute(String result) { if (result != null) { if (YouTubeApiServiceUtil.isYouTubeApiServiceAvailable(mActivity) .equals(YouTubeInitializationResult.SUCCESS)) { Intent intent = YouTubeStandalonePlayer.createVideoIntent(mActivity, MizLib.getYouTubeApiKey(mActivity), MizLib.getYouTubeId(result), 0, false, true); mActivity.startActivity(intent); } else {/*from w w w . j a va2s. c o m*/ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(result)); } } else { new YoutubeTrailerSearch(mActivity, mSearchQuery).execute(); } }
From source file:za.co.neilson.alarm.BaseActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { String url = null;//from w w w. ja v a 2s.c om Intent intent = null; switch (item.getItemId()) { case R.id.menu_item_join: startDialog(); break; case R.id.menu_item_new: startAlarmPreferencesActivity(); break; case R.id.menu_item_rate: url = "market://details?id=" + getPackageName(); intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); try { startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(this, "Couldn't launch the market", Toast.LENGTH_LONG).show(); } break; case R.id.menu_item_website: url = "http://www.neilson.co.za"; intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); try { startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(this, "Couldn't launch the website", Toast.LENGTH_LONG).show(); } break; case R.id.menu_item_report: url = "https://github.com/SheldonNeilson/Android-Alarm-Clock/issues"; intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); try { startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(this, "Couldn't launch the bug reporting website", Toast.LENGTH_LONG).show(); } /* Intent send = new Intent(Intent.ACTION_SENDTO); String uriText; String emailAddress = "dontusemyemailaddress@yourdomain.com"; String subject = R.string.app_name + " Bug Report"; String body = "Debug:"; body += "\n OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")"; body += "\n OS API Level: " + android.os.Build.VERSION.SDK_INT; body += "\n Device: " + android.os.Build.DEVICE; body += "\n Model (and Product): " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")"; body += "\n Screen Width: " + getWindow().getWindowManager().getDefaultDisplay().getWidth(); body += "\n Screen Height: " + getWindow().getWindowManager().getDefaultDisplay().getHeight(); body += "\n Hardware Keyboard Present: " + (getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS); uriText = "mailto:" + emailAddress + "?subject=" + subject + "&body=" + body; uriText = uriText.replace(" ", "%20"); Uri emalUri = Uri.parse(uriText); send.setData(emalUri); startActivity(Intent.createChooser(send, "Send mail...")); */ break; } return super.onOptionsItemSelected(item); }