当前位置: 首页>>代码示例>>C#>>正文


C# Android.Net.Uri.ToString方法代码示例

本文整理汇总了C#中Android.Net.Uri.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Android.Net.Uri.ToString方法的具体用法?C# Android.Net.Uri.ToString怎么用?C# Android.Net.Uri.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Net.Uri的用法示例。


在下文中一共展示了Android.Net.Uri.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetLocalPath

		/// <summary>
		/// Gets the local path.
		/// </summary>
		/// <param name="uri">The URI.</param>
		/// <returns>System.String.</returns>
		private static string GetLocalPath(Uri uri)
		{
			return new System.Uri(uri.ToString()).LocalPath;
		}
开发者ID:XnainA,项目名称:InsideInning,代码行数:9,代码来源:MediaPickerActivity.cs

示例2: GetFileForUriAsync

		/// <summary>
		/// Gets the file for URI asynchronous.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="uri">The URI.</param>
		/// <param name="isPhoto">if set to <c>true</c> [is photo].</param>
		/// <returns>Task&lt;Tuple&lt;System.String, System.Boolean&gt;&gt;.</returns>
		internal static Task<Tuple<string, bool>> GetFileForUriAsync(Context context, Uri uri, bool isPhoto)
		{
			var tcs = new TaskCompletionSource<Tuple<string, bool>>();

			if (uri.Scheme == "file")
				tcs.SetResult(new Tuple<string, bool>(new System.Uri(uri.ToString()).LocalPath, false));
			else if (uri.Scheme == "content")
			{
				Task.Factory.StartNew(() =>
				{
					ICursor cursor = null;
					try
					{
						cursor = context.ContentResolver.Query(uri, null, null, null, null);
						if (cursor == null || !cursor.MoveToNext())
							tcs.SetResult(new Tuple<string, bool>(null, false));
						else
						{
							int column = cursor.GetColumnIndex(MediaStore.MediaColumns.Data);
							string contentPath = null;

							if (column != -1)
								contentPath = cursor.GetString(column);

							bool copied = false;

							// If they don't follow the "rules", try to copy the file locally
//							if (contentPath == null || !contentPath.StartsWith("file"))
//							{
//								copied = true;
//								Uri outputPath = GetOutputMediaFile(context, "temp", null, isPhoto);
//
//								try
//								{
//									using (Stream input = context.ContentResolver.OpenInputStream(uri))
//									using (Stream output = File.Create(outputPath.Path))
//										input.CopyTo(output);
//
//									contentPath = outputPath.Path;
//								}
//								catch (FileNotFoundException)
//								{
//									// If there's no data associated with the uri, we don't know
//									// how to open this. contentPath will be null which will trigger
//									// MediaFileNotFoundException.
//								}
//							}

							tcs.SetResult(new Tuple<string, bool>(contentPath, copied));
						}
					}
					finally
					{
						if (cursor != null)
						{
							cursor.Close();
							cursor.Dispose();
						}
					}
				}, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
			}
			else
				tcs.SetResult(new Tuple<string, bool>(null, false));

			return tcs.Task;
		}
开发者ID:XnainA,项目名称:InsideInning,代码行数:73,代码来源:MediaPickerActivity.cs

示例3: SetImageURI

 public override void SetImageURI(Uri uri)
 {
     base.SetImageURI(uri);
     var stream = Application.Context.ContentResolver.OpenInputStream(uri);
     var drawable = Drawable.CreateFromStream(stream, uri.ToString());
     _mBitmap = GetBitmapFromDrawable(drawable);
     Setup();
 }
开发者ID:blocke79,项目名称:CircleImageView-Xamarin,代码行数:8,代码来源:CircleImageView.cs

示例4: GetMediaFileAsync

		/// <summary>
		/// Gets the media file asynchronous.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="requestCode">The request code.</param>
		/// <param name="action">The action.</param>
		/// <param name="isPhoto">if set to <c>true</c> [is photo].</param>
		/// <param name="path">The path.</param>
		/// <param name="data">The data.</param>
		/// <returns>Task&lt;MediaPickedEventArgs&gt;.</returns>
		internal static Task<MediaPickedEventArgs> GetMediaFileAsync(Context context, int requestCode, string action,
			bool isPhoto, ref Uri path, Uri data)
		{
			Task<Tuple<string, bool>> pathFuture;
			Action<bool> dispose = null;
			string originalPath = null;

			if (action != Intent.ActionPick)
			{
				originalPath = path.Path;

				// Not all camera apps respect EXTRA_OUTPUT, some will instead
				// return a content or file uri from data.
				if (data != null && data.Path != originalPath)
				{
					originalPath = data.ToString();
					var currentPath = path.Path;

					pathFuture = TryMoveFileAsync(context, data, path, isPhoto).ContinueWith(t =>
						new Tuple<string, bool>(t.Result ? currentPath : null, false));
				}
				else
					pathFuture = TaskUtils.TaskFromResult(new Tuple<string, bool>(path.Path, false));
			}
			else if (data != null)
			{
				originalPath = data.ToString();
				path = data;
				pathFuture = GetFileForUriAsync(context, path, isPhoto);
			}
			else
			{
				pathFuture = TaskUtils.TaskFromResult<Tuple<string, bool>>(null);
			}

			return pathFuture.ContinueWith(t =>
			{
				string resultPath = t.Result.Item1;
				if (resultPath != null && File.Exists(t.Result.Item1))
				{
					if (t.Result.Item2)
					{
						dispose = d => File.Delete(resultPath);
					}

					var mf = new MediaFile(resultPath, () => File.OpenRead(t.Result.Item1) , dispose);

					return new MediaPickedEventArgs(requestCode, false, mf);
				}
				return new MediaPickedEventArgs(requestCode, new MediaFileNotFoundException(originalPath));
			});
		}
开发者ID:XnainA,项目名称:InsideInning,代码行数:62,代码来源:MediaPickerActivity.cs

示例5: HtmlElement

 public HtmlElement(string caption, Uri uri)
     : base(caption, uri.ToString(), "dialog_labelfieldright")
 {
     Url = uri;
 }
开发者ID:runegri,项目名称:Android.Dialog,代码行数:5,代码来源:HtmlElement.cs


注:本文中的Android.Net.Uri.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。