本文整理汇总了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;
}
示例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<Tuple<System.String, System.Boolean>>.</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;
}
示例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();
}
示例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<MediaPickedEventArgs>.</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));
});
}
示例5: HtmlElement
public HtmlElement(string caption, Uri uri)
: base(caption, uri.ToString(), "dialog_labelfieldright")
{
Url = uri;
}