List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java
/** * when user click common to Webview./*from w w w. ja v a 2 s .c o m*/ * * @param activity * @param url */ protected void onClickCommon(String url) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); }
From source file:com.phonegap.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 w w. j a v a 2s.c om public String openExternal(String url, boolean usePhoneGap) { try { Intent intent = null; if (usePhoneGap) { intent = new Intent().setClass(this.ctx, com.phonegap.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:com.phonegap.plugins.slaveBrowser.SlaveBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load./* www. jav a 2 s . c om*/ * @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.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, "Error loading url " + url + ":" + e.toString()); return e.toString(); } }
From source file:com.mercandalli.android.apps.files.user.LoginRegisterActivity.java
private void requestAccountPermissionInSettings() { Snackbar.make(findViewById(R.id.activity_register_login_signin), "FileSpace needs the Contacts permission for using Google.", Snackbar.LENGTH_LONG) .setAction(android.R.string.ok, new View.OnClickListener() { @Override/*ww w . ja v a 2 s . c om*/ public void onClick(View view) { final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + getPackageName())); startActivity(intent); } }).show(); }
From source file:com.xtensive.plugins.pdfviewer.PDFViewer.java
/** * Display a MuPDF with the specified URL. *//from w w w .j a v a 2s . c om * @param path The path to load. * @return "" if ok, or error message. */ public String openPDF(final String path) { try { cordova.getThreadPool().execute(new Runnable() { @Override public void run() { Context context = cordova.getActivity().getApplicationContext(); Intent intent = new Intent(context, MuPDFActivity.class); intent.setAction(Intent.ACTION_VIEW); //String fileName = Environment.getExternalStorageDirectory().toString() + "/" + path; String fileName = path; Log.d(LOG_TAG, "DEBUG load: " + fileName); intent.setData(Uri.parse(fileName)); cordova.getActivity().startActivityForResult(intent, XRI_LINK_CLIKED); } }); return ""; } catch (android.content.ActivityNotFoundException e) { Log.e(LOG_TAG, "Error loading url " + path + ":" + e.toString()); return e.toString(); } }
From source file:com.ferasinfotech.gwreader.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View.OnLongClickListener click_listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { Intent i = new Intent(Intent.ACTION_VIEW); String s = "https://www.grasswire.com"; if (mStoryID != 0) { s = s + "/story/" + mStoryID + "/x"; }/*w ww. j a v a 2 s. co m*/ i.setData(Uri.parse(s)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); return true; } }; ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false); // Picasso.with(getActivity()).setLoggingEnabled(true); // Picasso.with(getActivity()).setIndicatorsEnabled(true); ImageView cover_image = (ImageView) rootView.findViewById(R.id.story_image); Picasso.with(getActivity()).load(mCoverPhoto).into(cover_image); cover_image.setOnLongClickListener(click_listener); ((TextView) rootView.findViewById(R.id.story_title)).setText(mTitle); ((TextView) rootView.findViewById(R.id.story_headline)).setText(mHeadline); ((TextView) rootView.findViewById(R.id.story_summary)).setText(mSummary); Log.d("***DEBUG***", "Building page:" + mPageNumber); if (mStoryID != 0) { LinksAdapter adapter = new LinksAdapter(getActivity(), mStoryString); LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.story_layout); for (int i = 0; i < adapter.getCount(); i++) { View listItem = adapter.getView(i, null, ll); ll.addView(listItem); } } return rootView; }
From source file:com.z.stproperty.PropertyDetailFragment.java
/** * onClick :: OnClickListener// w ww . ja va 2 s .c o m * * Is common on-click listener for all the buttons and images in home screen * This is grouped into single listener to make easier to alter the code and reduce the * line of code. * * This will check the View ID to match with the predefined View-ID to identify * which view is clicked * * Based on the view id this will perform different functionalities */ private void performClickAction(View v) { try { switch (v.getId()) { case R.id.LoanCalculator: Intent calIntent = new Intent(getActivity(), LoanCalculator.class); calIntent.putExtra("price", price); startActivity(calIntent); break; case R.id.AgentMobile: String url = "tel:" + mobileNoStr; url = url.replace("+65-", ""); Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse(url)); startActivity(callIntent); break; case R.id.SendEmailBtn: String text = "I'm interested in your property advertised on STProperty\n\n" + "PROPERTY TITLE:" + title + "\n" + "PRICE:" + price + "\n\nClick on the following link to view more details about the property\n\n" + prurl; Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { agentEmail }); intent.putExtra(Intent.EXTRA_SUBJECT, "Enquiry"); intent.putExtra(Intent.EXTRA_TEXT, text); SharedFunction.postAnalytics(PropertyDetailFragment.this.getActivity(), "Lead", "Successful Email Enquiry", title); startActivity(Intent.createChooser(intent, "")); break; /**case R.id.SendEnquiryBtn: Intent enqInt = new Intent(getActivity(), SaleEnquiry.class); enqInt.putExtra("propertyId", detailsJson.getString("id")); enqInt.putExtra("agentId", detailsJson.getJSONObject("seller_info").getString("agent_cea_reg_no")); startActivity(enqInt); break;*/ default: break; } } catch (Exception e) { Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage(), e); } }
From source file:com.doplgangr.secrecy.settings.SettingsFragment.java
private void confirm_stealth(String password) { final View dialogView = View.inflate(context, R.layout.dialog_confirm_stealth, null); ((TextView) dialogView.findViewById(R.id.stealth_keycode)).append(password); new AlertDialog.Builder(context).setInverseBackgroundForced(true).setView(dialogView) .setMessage(R.string.Settings__try_once_before_hide) .setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context) .edit();/*ww w . j a va 2s . co m*/ editor.putBoolean(Config.SHOW_STEALTH_MODE_TUTORIAL, true); editor.apply(); Intent dial = new Intent(); dial.setAction("android.intent.action.DIAL"); dial.setData(Uri.parse("tel:")); dial.setFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(dial); getActivity().finish(); } }).show(); }
From source file:com.projectgoth.mywebrtcdemo.ConnectActivity.java
private void connectToRoom(boolean loopback, int runTimeMs) { // Get room name (random for loopback). String roomId;/*from w w w .j av a 2 s .c om*/ if (loopback) { roomId = Integer.toString((new Random()).nextInt(100000000)); } else { roomId = getSelectedItem(); if (roomId == null) { roomId = roomEditText.getText().toString(); } } String roomUrl = sharedPref.getString(keyprefRoomServerUrl, getString(R.string.pref_room_server_url_default)); // Video call enabled flag. boolean videoCallEnabled = sharedPref.getBoolean(keyprefVideoCallEnabled, Boolean.valueOf(getString(R.string.pref_videocall_default))); // Get default codecs. String videoCodec = sharedPref.getString(keyprefVideoCodec, getString(R.string.pref_videocodec_default)); String audioCodec = sharedPref.getString(keyprefAudioCodec, getString(R.string.pref_audiocodec_default)); // Check HW codec flag. boolean hwCodec = sharedPref.getBoolean(keyprefHwCodecAcceleration, Boolean.valueOf(getString(R.string.pref_hwcodec_default))); // Check Capture to texture. boolean captureToTexture = sharedPref.getBoolean(keyprefCaptureToTexture, Boolean.valueOf(getString(R.string.pref_capturetotexture_default))); // Check Disable Audio Processing flag. boolean noAudioProcessing = sharedPref.getBoolean(keyprefNoAudioProcessingPipeline, Boolean.valueOf(getString(R.string.pref_noaudioprocessing_default))); // Check Disable Audio Processing flag. boolean aecDump = sharedPref.getBoolean(keyprefAecDump, Boolean.valueOf(getString(R.string.pref_aecdump_default))); // Check OpenSL ES enabled flag. boolean useOpenSLES = sharedPref.getBoolean(keyprefOpenSLES, Boolean.valueOf(getString(R.string.pref_opensles_default))); // Get video resolution from settings. int videoWidth = 0; int videoHeight = 0; String resolution = sharedPref.getString(keyprefResolution, getString(R.string.pref_resolution_default)); String[] dimensions = resolution.split("[ x]+"); if (dimensions.length == 2) { try { videoWidth = Integer.parseInt(dimensions[0]); videoHeight = Integer.parseInt(dimensions[1]); } catch (NumberFormatException e) { videoWidth = 0; videoHeight = 0; Log.e(TAG, "Wrong video resolution setting: " + resolution); } } // Get camera fps from settings. int cameraFps = 0; String fps = sharedPref.getString(keyprefFps, getString(R.string.pref_fps_default)); String[] fpsValues = fps.split("[ x]+"); if (fpsValues.length == 2) { try { cameraFps = Integer.parseInt(fpsValues[0]); } catch (NumberFormatException e) { Log.e(TAG, "Wrong camera fps setting: " + fps); } } // Check capture quality slider flag. boolean captureQualitySlider = sharedPref.getBoolean(keyprefCaptureQualitySlider, Boolean.valueOf(getString(R.string.pref_capturequalityslider_default))); // Get video and audio start bitrate. int videoStartBitrate = 0; String bitrateTypeDefault = getString(R.string.pref_startvideobitrate_default); String bitrateType = sharedPref.getString(keyprefVideoBitrateType, bitrateTypeDefault); if (!bitrateType.equals(bitrateTypeDefault)) { String bitrateValue = sharedPref.getString(keyprefVideoBitrateValue, getString(R.string.pref_startvideobitratevalue_default)); videoStartBitrate = Integer.parseInt(bitrateValue); } int audioStartBitrate = 0; bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_default); bitrateType = sharedPref.getString(keyprefAudioBitrateType, bitrateTypeDefault); if (!bitrateType.equals(bitrateTypeDefault)) { String bitrateValue = sharedPref.getString(keyprefAudioBitrateValue, getString(R.string.pref_startaudiobitratevalue_default)); audioStartBitrate = Integer.parseInt(bitrateValue); } // Check statistics display option. boolean displayHud = sharedPref.getBoolean(keyprefDisplayHud, Boolean.valueOf(getString(R.string.pref_displayhud_default))); boolean tracing = sharedPref.getBoolean(keyprefTracing, Boolean.valueOf(getString(R.string.pref_tracing_default))); // Start AppRTCDemo activity. Log.d(TAG, "Connecting to room " + roomId + " at URL " + roomUrl); if (validateUrl(roomUrl)) { Uri uri = Uri.parse(roomUrl); Intent intent = new Intent(this, CallActivity.class); intent.setData(uri); intent.putExtra(CallActivity.EXTRA_ROOMID, roomId); intent.putExtra(CallActivity.EXTRA_LOOPBACK, loopback); intent.putExtra(CallActivity.EXTRA_VIDEO_CALL, videoCallEnabled); intent.putExtra(CallActivity.EXTRA_VIDEO_WIDTH, videoWidth); intent.putExtra(CallActivity.EXTRA_VIDEO_HEIGHT, videoHeight); intent.putExtra(CallActivity.EXTRA_VIDEO_FPS, cameraFps); intent.putExtra(CallActivity.EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABLED, captureQualitySlider); intent.putExtra(CallActivity.EXTRA_VIDEO_BITRATE, videoStartBitrate); intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, videoCodec); intent.putExtra(CallActivity.EXTRA_HWCODEC_ENABLED, hwCodec); intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, captureToTexture); intent.putExtra(CallActivity.EXTRA_NOAUDIOPROCESSING_ENABLED, noAudioProcessing); intent.putExtra(CallActivity.EXTRA_AECDUMP_ENABLED, aecDump); intent.putExtra(CallActivity.EXTRA_OPENSLES_ENABLED, useOpenSLES); intent.putExtra(CallActivity.EXTRA_AUDIO_BITRATE, audioStartBitrate); intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, audioCodec); intent.putExtra(CallActivity.EXTRA_DISPLAY_HUD, displayHud); intent.putExtra(CallActivity.EXTRA_TRACING, tracing); intent.putExtra(CallActivity.EXTRA_CMDLINE, commandLineRun); intent.putExtra(CallActivity.EXTRA_RUNTIME, runTimeMs); startActivityForResult(intent, CONNECTION_REQUEST); } }
From source file:com.partytv.server.PartyTvServer.java
private void checkAppKeySetup() { // Check to make sure that we have a valid app key if (APP_KEY.startsWith("CHANGE") || APP_SECRET.startsWith("CHANGE")) { showToast(//w ww .j av a 2s.c o m "You must apply for an app key and secret from developers.dropbox.com, and add them to the DBRoulette ap before trying it."); finish(); return; } // Check if the app has set up its manifest properly. Intent testIntent = new Intent(Intent.ACTION_VIEW); String scheme = "db-" + APP_KEY; String uri = scheme + "://" + AuthActivity.AUTH_VERSION + "/test"; testIntent.setData(Uri.parse(uri)); PackageManager pm = getPackageManager(); if (0 == pm.queryIntentActivities(testIntent, 0).size()) { showToast("URL scheme in your app's " + "manifest is not set up correctly. You should have a " + "com.dropbox.client2.android.AuthActivity with the " + "scheme: " + scheme); finish(); } }