标签: uri

替换Uri中的主机

使用.NET替换Uri的主机部分最好的方法是什么?

即:

string ReplaceHost(string original, string newHostName);
//...
string s = ReplaceHost("http://oldhostname/index.html", "newhostname");
Assert.AreEqual("http://newhostname/index.html", s);
//...
string s = ReplaceHost("http://user:pass@oldhostname/index.html", "newhostname");
Assert.AreEqual("http://user:pass@newhostname/index.html", s);
//...
string s = ReplaceHost("ftp://user:pass@oldhostname", "newhostname");
Assert.AreEqual("ftp://user:pass@newhostname", s);
//etc.
Run Code Online (Sandbox Code Playgroud)

System.Uri似乎没什么帮助.

.net c# uri

77
推荐指数
2
解决办法
3万
查看次数

我如何获得具有其Uri的文件的mime类型?

我有一个用画廊和相机获得的Uris列表.这些Uris是这样的:content://media/external/images/media/94.我怎么能得到它的mime类型?

android uri mime-types

77
推荐指数
4
解决办法
5万
查看次数

如何在没有(to)部分的情况下创建mailto:link

你如何正确构建一个没有该部分的mailto:link. mailto:someaddress@example.com? 我不想要地址,只是想在之后的参数中通过mailto填写.

mailto uri

76
推荐指数
2
解决办法
3万
查看次数

Uri.Host和Uri.Authority有什么区别

System.UriHost,AuthorityDnsSafeHost.MS提供时的一个很好的例子Host,并DnsSafeHost在不同的位置.

我想要一个类似的例子/解释HostAuthority.

.net c# uri

74
推荐指数
5
解决办法
3万
查看次数

如何使用"共享图像使用"共享Intent在android中共享图像?

我在该应用程序中有图像厨房应用程序我将所有图像放入drawable-hdpi文件夹中.我在我的活动中调用了这样的图像:

private Integer[] imageIDs = {
        R.drawable.wall1, R.drawable.wall2,
        R.drawable.wall3, R.drawable.wall4,
        R.drawable.wall5, R.drawable.wall6,
        R.drawable.wall7, R.drawable.wall8,
        R.drawable.wall9, R.drawable.wall10
};
Run Code Online (Sandbox Code Playgroud)

所以现在我想知道我如何使用共享Intent我分享这些图像我推出的共享代码如下:

     Button shareButton = (Button) findViewById(R.id.share_button);
     shareButton.setOnClickListener(new View.OnClickListener() {
     public void onClick(View v) {

        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        Uri screenshotUri = Uri.parse(Images.Media.EXTERNAL_CONTENT_URI + "/" + imageIDs);

        sharingIntent.setType("image/jpeg");
        sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
        startActivity(Intent.createChooser(sharingIntent, "Share image using"));  

         }
    });
Run Code Online (Sandbox Code Playgroud)

当我点击分享按钮时我也有共享按钮分享框正在打开但当我克服任何服务时,大多数崩溃或一些服务说:无法打开图像所以我怎么能解决这个问题或者是否有任何其他格式代码来共享图像????

编辑:

我尝试使用下面的代码.但它不起作用.

Button shareButton = (Button) findViewById(R.id.share_button);
     shareButton.setOnClickListener(new View.OnClickListener() {
     public void onClick(View v) {

        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        Uri screenshotUri = Uri.parse("android.resource://com.android.test/*");
        try { …
Run Code Online (Sandbox Code Playgroud)

android share uri image

71
推荐指数
9
解决办法
16万
查看次数

What do you call the entire first part of a URL?

If I have a URL like:

http://www.example.com:9090/test.html
Run Code Online (Sandbox Code Playgroud)

Then I know that www.example.com is the host name, but what do you call http://www.example.com:9090? Is there some kind of established name for that?

url uri terminology

68
推荐指数
4
解决办法
3万
查看次数

在C++跨平台上解析url的简单方法?

我需要解析一个URL,以便在我用C++编写的应用程序中获取协议,主机,路径和查询.该应用程序旨在跨平台.我很惊讶我在boostPOCO库中找不到任何这样的功能.这是显而易见的我不看的地方吗?关于适当的开源库的任何建议?或者这是我必须自己做的事情?它并不是非常复杂,但似乎是一项常见的任务,我很惊讶没有一个共同的解决方案.

c++ url uri

67
推荐指数
9
解决办法
8万
查看次数

在Android中将文件路径转换为Uri

我有一个应用程序,我使用相机捕获视频.我可以获得视频的文件路径,但我需要它作为Uri.

我得到的文件路径:

/storage/emulated/0/DCIM/Camera/20141219_133139.mp4
Run Code Online (Sandbox Code Playgroud)

我需要的是这样的:

content//media/external/video/media/18576.
Run Code Online (Sandbox Code Playgroud)

这是我的代码.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // if the result is capturing Image

         if (requestCode == CAMERA_CAPTURE_VIDEO_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                // video successfully recorded
                // preview the recorded video
                // selectedImageUri = data.getData();
                // Uri selectedImage = data.getData();
                previewVideo();

                tv1.setText(String.valueOf((fileUri.getPath())));
                String bedroom=String.valueOf((fileUri.getPath()));
                Intent i = new Intent();
                i.putExtra(bhk1.BEDROOM2, bedroom);
                setResult(RESULT_OK,i); 
                btnRecordVideo.setText("ReTake Video");

            } else if (resultCode == RESULT_CANCELED) {
                // user cancelled recording
                Toast.makeText(getApplicationContext(),
                        "User cancelled video recording", …
Run Code Online (Sandbox Code Playgroud)

string android uri

67
推荐指数
3
解决办法
11万
查看次数

从Microsoft.AspNet.Http.HttpRequest获取原始URL

HttpRequest在Asp.Net 5(vNext)类包含(除其他事项外)解析有关的URL请求,诸如细节Scheme,Host,Path等.

我还没有发现任何公开原始请求URL的地方 - 只有这些解析的值.(以前的版本有Request.Uri)

我可以获取原始URL而无需将其与HttpRequest上可用的组件拼凑在一起吗?

uri request asp.net-core

63
推荐指数
7
解决办法
4万
查看次数

如何检查uri字符串是否有效

如何检查uri字符串是否有效(您可以将其提供给Uri构造函数)?

到目前为止,我只有以下内容,但由于显而易见的原因,我更喜欢不那么粗野的方式:

    Boolean IsValidUri(String uri)
    {
        try
        {
            new Uri(uri);
            return true;
        }
        catch
        {
            return false;
        }
    }
Run Code Online (Sandbox Code Playgroud)

我尝试了Uri.IsWellFormedUriString,但它似乎并不喜欢你可以在构造函数中抛出的所有内容.例如:

String test = @"C:\File.txt";
Console.WriteLine("Uri.IsWellFormedUriString says: {0}", Uri.IsWellFormedUriString(test, UriKind.RelativeOrAbsolute));
Console.WriteLine("IsValidUri says: {0}", IsValidUri(test));
Run Code Online (Sandbox Code Playgroud)

输出将是:

Uri.IsWellFormedUriString says: False
IsValidUri says: True
Run Code Online (Sandbox Code Playgroud)

更新/应答

Uri构造函数默认使用类Absolute.当我尝试使用Uri.TryCreate和构造函数时,这导致了差异.如果匹配构造函数和TryCreate的UriKind,则会获得预期的结果.

.net c# uri

62
推荐指数
3
解决办法
8万
查看次数

标签 统计

uri ×10

.net ×3

android ×3

c# ×3

url ×2

asp.net-core ×1

c++ ×1

image ×1

mailto ×1

mime-types ×1

request ×1

share ×1

string ×1

terminology ×1