List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private void refreshQrCode(File qrCode) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(Uri.fromFile(qrCode)); sendBroadcast(mediaScanIntent);/*from w w w .j a v a 2 s . c om*/ }
From source file:com.csipsimple.wizards.impl.OneWorld.java
private void updateAccountInfos(final SipProfile acc) { if (acc != null && acc.id != SipProfile.INVALID_ID) { setFirstViewVisibility(false);// w ww . j a va2s . c o m customWizard.setVisibility(View.VISIBLE); customWizard.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String url = "http://www.1worldsip.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); parent.startActivity(i); } }); accountBalanceHelper.launchRequest(acc); } else { if (firstView == null) { firstView = new AccountCreationFirstView(parent); ViewGroup globalContainer = (ViewGroup) settingsContainer.getParent(); firstView.setOnAccountCreationFirstViewListener(this); globalContainer.addView(firstView); } setFirstViewVisibility(true); } }
From source file:com.app.plugins.childBrowser.ChildBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param usePhoneGap Load url in PhoneGap webview * @return "" if ok, or error message. *///w ww. j a v a2s. co m public String openExternal(String url, boolean usePhoneGap) { try { Intent intent = null; if (usePhoneGap) { intent = new Intent().setClass(this.cordova.getActivity(), DroidGap.class); intent.setData(Uri.parse(url)); // This line will be removed in future. intent.putExtra("url", url); // Timeout parameter: 60 sec max - May be less if http device timeout is less. intent.putExtra("loadUrlTimeoutValue", 60000); // These parameters can be configured if you want to show the loading dialog intent.putExtra("loadingDialog", "Wait,Loading web page..."); // show loading dialog intent.putExtra("hideLoadingDialogOnPageLoad", true); // hide it once page has completely loaded } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); } this.cordova.getActivity().startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { Log.d(LOG_TAG, "ChildBrowser: Error loading url " + url + ":" + e.toString()); return e.toString(); } }
From source file:com.dawsonloudon.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 w w . j a v a 2 s .co m*/ 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:me.piebridge.prevent.ui.UserGuideActivity.java
private boolean donateViaAlipay() { showDonateDialog();//from ww w. java 2 s . com Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(BuildConfig.DONATE_ALIPAY)); try { startActivity(intent); } catch (Throwable t) { // NOSONAR hideDonateDialog(); } return true; }
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();// w w w.j a v a 2 s . 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.mono.applink.Facebook.java
/** Called when the activity is first created. */ @Override/*from www . j a v a 2 s .c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; final String url = getIntent().getData().toString(); if (url.contains("posts") || url.contains("profile.php") || (!url.contains("&") && !url.contains("=") && url.length() > 24)) //1)Posts->It is impossible to launch FeedbackActivity because of permission denied. //With root permission and "am start" it's impossible to pass a Long extra_key... //2)Profile //3)Nickname { new FacebookUser().execute(); } else if (url.contains("sk=inbox"))//Message { new FacebookMessage().execute(); } else if (url.contains("event.php"))//event { new FacebookEvent().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.dhaval.mobile.plugin.ChildBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param usePhoneGap Load url in PhoneGap webview * @return "" if ok, or error message. *///from ww w. ja va2 s .c o m public String openExternal(String url, boolean usePhoneGap) { try { Intent intent = null; if (usePhoneGap) { intent = new Intent().setClass(this.ctx.getContext(), org.apache.cordova.DroidGap.class); intent.setData(Uri.parse(url)); // This line will be removed in future. intent.putExtra("url", url); // Timeout parameter: 60 sec max - May be less if http device timeout is less. intent.putExtra("loadUrlTimeoutValue", 60000); // These parameters can be configured if you want to show the loading dialog intent.putExtra("loadingDialog", "Wait,Loading web page..."); // show loading dialog intent.putExtra("hideLoadingDialogOnPageLoad", true); // hide it once page has completely loaded } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); } this.ctx.startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { Log.d(LOG_TAG, "ChildBrowser: Error loading url " + url + ":" + e.toString()); return e.toString(); } }
From source file:de.electricdynamite.pasty.ClipboardFragment.java
@SuppressLint("NewApi") public boolean onContextItemSelected(android.view.MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int menuItemIndex = item.getItemId(); ClipboardItem Item = mItems.get(info.position); switch (menuItemIndex) { case PastySharedStatics.ITEM_CONTEXTMENU_COPY_ID: // Copy without exit selected if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSherlockActivity() .getSystemService(Context.CLIPBOARD_SERVICE); Item.copyToClipboard(clipboard); clipboard = null;/* w w w . j a v a 2s .c om*/ } else { ClipboardManager clipboard = (ClipboardManager) getSherlockActivity() .getSystemService(Context.CLIPBOARD_SERVICE); Item.copyToClipboard(clipboard); clipboard = null; } Toast.makeText(getSherlockActivity().getApplicationContext(), getString(R.string.item_copied), Toast.LENGTH_LONG).show(); break; case PastySharedStatics.ITEM_CONTEXTMENU_SHARE_ID: // Share to another app Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, Item.getText()); startActivity(Intent.createChooser(shareIntent, getString(R.string.app_share_from_pasty))); break; case PastySharedStatics.ITEM_CONTEXTMENU_DELETE_ID: // Delete selected mAdapter.delete(info.position); break; case PastySharedStatics.ITEM_CONTEXTMENU_OPEN_ID: /* If the clicked item was originally linkified, we * fire an ACTION_VIEW intent. */ String url = Item.getText(); if (!URLUtil.isValidUrl(url)) url = "http://" + url; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); break; } return true; }
From source file:com.phonegap.plugins.ChildBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load./*from w w w . j a v a 2 s . c o m*/ * @param usePhoneGap Load url in PhoneGap webview * @return "" if ok, or error message. */ public String openExternal(String url, boolean usePhoneGap) { try { Intent intent = null; if (usePhoneGap) { intent = new Intent().setClass(this.cordova.getActivity(), org.apache.cordova.DroidGap.class); intent.setData(Uri.parse(url)); // This line will be removed in future. intent.putExtra("url", url); // Timeout parameter: 60 sec max - May be less if http device timeout is less. intent.putExtra("loadUrlTimeoutValue", 60000); // These parameters can be configured if you want to show the loading dialog intent.putExtra("loadingDialog", "Wait,Loading web page..."); // show loading dialog intent.putExtra("hideLoadingDialogOnPageLoad", true); // hide it once page has completely loaded } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); } this.cordova.getActivity().startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { Log.d(LOG_TAG, "ChildBrowser: Error loading url " + url + ":" + e.toString()); return e.toString(); } }