本文整理汇总了C#中Android.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Android.ToString方法的具体用法?C# Android.ToString怎么用?C# Android.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android
的用法示例。
在下文中一共展示了Android.ToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenFile
public override ParcelFileDescriptor OpenFile(Android.Net.Uri uri, String mode)
{
const string logTag = ClassName + " - openFile";
Log.Verbose(logTag,
"Called with uri: '" + uri + "'." + uri.LastPathSegment);
if (uri.ToString().StartsWith("content://" + Authority))
{
// The desired file name is specified by the last segment of the
// path
// E.g.
// 'content://keepass2android.provider/Test.txt'
// Take this and build the path to the file
String fileLocation = Context.CacheDir + File.Separator + AttachmentCacheSubDir + File.Separator
+ uri.LastPathSegment;
// Create & return a ParcelFileDescriptor pointing to the file
// Note: I don't care what mode they ask for - they're only getting
// read only
ParcelFileDescriptor pfd = ParcelFileDescriptor.Open(new File(
fileLocation), ParcelFileMode.ReadOnly);
return pfd;
}
Log.Verbose(logTag, "Unsupported uri: '" + uri + "'.");
throw new FileNotFoundException("Unsupported uri: "
+ uri.ToString());
}
示例2: OnError
public bool OnError(MediaPlayer mp, Android.Media.MediaError e, int s)
{
#if DEBUG
Console.WriteLine("{0}", e.ToString());
#endif
return true;
}
示例3: DownloadDocument
public static async Task<Android.Net.Uri> DownloadDocument (Context ctx, Android.Net.Uri uriToDownload, string saveFilePath, IProgress<DownloadBytesProgress> progessReporter)
{
int receivedBytes = 0;
int totalBytes = 0;
using (var assetFileDescriptor = ctx.ContentResolver.OpenAssetFileDescriptor (uriToDownload, "r"))
using (var fileOutputStream = new Java.IO.FileOutputStream (saveFilePath))
using (var inputStream = assetFileDescriptor.CreateInputStream ()) {
var buffer = new byte [BufferSize];
totalBytes = (int)assetFileDescriptor.Length;
for (;;) {
var bytesRead = await inputStream.ReadAsync (buffer, 0, buffer.Length);
if (bytesRead == 0) {
await Task.Yield();
break;
}
await fileOutputStream.WriteAsync (buffer, 0, buffer.Length);
receivedBytes += bytesRead;
if (progessReporter != null) {
var args = new DownloadBytesProgress (uriToDownload.ToString (), saveFilePath, receivedBytes, totalBytes);
progessReporter.Report(args);
}
}
inputStream.Close ();
fileOutputStream.Close ();
}
var file = new Java.IO.File (saveFilePath);
var docUri = Android.Net.Uri.FromFile (file);
return docUri;
}
示例4: OpenFile
public override ParcelFileDescriptor OpenFile(Android.Net.Uri uri, string mode)
{
string fileName = uri.ToString ().Substring (CONTENT_URI.ToString ().Length);
System.Console.WriteLine (fileName + " - File to open in external app");
if (System.IO.File.Exists (fileName)) {
return ParcelFileDescriptor.Open(new Java.IO.File(fileName), ParcelFileMode.ReadOnly);
}
return null;
}
示例5: ShowPdfDocument
void ShowPdfDocument (Android.Net.Uri docUri)
{
// Customize thumbnailBar color defaults
var thumbnailBarThemeConfiguration = new ThumbnailBarThemeConfiguration.Builder (this)
.SetBackgroundColor (Android.Graphics.Color.Argb (255, 52, 152, 219))
.SetThumbnailBorderColor (Android.Graphics.Color.Argb (255, 44, 62, 80))
.Build ();
// Show Document using PSPDFKit activity
var pspdfkitConfiguration = new PSPDFActivityConfiguration.Builder (ApplicationContext, yourLicenseKey)
.ScrollDirection (PageScrollDirection.Horizontal)
.ShowPageNumberOverlay ()
.ShowThumbnailGrid ()
.ShowThumbnailBar ()
.ThumbnailBarThemeConfiguration (thumbnailBarThemeConfiguration)
.Build ();
if (!PSPDFKitGlobal.IsOpenableUri (this, docUri))
ShowError ("This document uri cannot be opened \n " + docUri.ToString ());
else
PSPDFAppCompatActivity.ShowDocument (this, docUri, pspdfkitConfiguration);
}
示例6: GetPathToImage
private string GetPathToImage(Android.Net.Uri uri)
{
string doc_id = "";
try{
using (var c1 = Application.Context.ContentResolver.Query (uri, null, null, null, null)) {
c1.MoveToFirst ();
String document_id = c1.GetString (0);
doc_id = document_id.Substring (document_id.LastIndexOf (":") + 1);
}
}catch{
Log.Debug ("GetPathToImage","Excepcion! El content es File");
Android.Content.Context context = Android.App.Application.Context;
try{
String[] proj = { MediaStore.MediaColumns.Data };
Log.Debug ("GetPathToImage","Y la URI? "+uri.ToString());
// var c1 = context.ContentResolver.Query (uri, proj, null, null, null)
var loader = new CursorLoader (context, uri, proj, null, null, null);
var c1 = (ICursor)loader.LoadInBackground();
if(c1==null){
Log.Debug ("GetPathToImage","Sigue siendo nulo-");
}
c1.MoveToFirst ();
Log.Debug ("GetPathToImage","Pasamos?");
String document_id = c1.GetString (0);
doc_id = document_id.Substring (document_id.LastIndexOf (":") + 1);
Log.Debug ("GetPathToImage","Y bien? "+doc_id);
}
catch(Exception ex){
Log.Debug ("GetPathToImage","Excepcion! "+ex);
}
}
string path = null;
// The projection contains the columns we want to return in our query.
string selection = Android.Provider.MediaStore.Images.Media.InterfaceConsts.Id + " =? ";
using (var cursor = Application.Context.ContentResolver.Query(Android.Provider.MediaStore.Images.Media.ExternalContentUri, null, selection, new string[] {doc_id}, null))
{
if (cursor == null) return path;
var columnIndex = cursor.GetColumnIndexOrThrow(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data);
cursor.MoveToFirst();
path = cursor.GetString(columnIndex);
//cursor.Close ();
}
return path;
}
示例7: OnContextItemSelected
public override bool OnContextItemSelected (Android.Views.IMenuItem item)
{
//Note how this callback is using the fully-qualified class name
Toast.MakeText (this, "Got click: " + item.ToString (), ToastLength.Short).Show ();
return true;
}
示例8: OnError
public bool OnError(Android.Media.MediaPlayer mp, Android.Media.MediaError what, int extra)
{
this.RootPlayer.FireError (what.ToString ());
return true;
}
示例9: OnError
public bool OnError (Android.Media.MediaPlayer mp, Android.Media.MediaError what, int extra)
{
this.ParentElement.HasError = true;
this.ParentElement.ErrorMessage = what.ToString ();
this._HasEnded = true;
// true handle, false allow pass
return false;
}
示例10: GetType
public override string GetType (Android.Net.Uri uri)
{
var mimeType = MimeTypeHelper.GetMimeType(uri.ToString());
return mimeType;
}
示例11: ShowPdfDocument
void ShowPdfDocument(Android.Net.Uri docUri, string filename)
{
// Customize thumbnailBar color defaults
var thumbnailBarThemeConfiguration = new ThumbnailBarThemeConfiguration.Builder (Forms.Context)
.SetBackgroundColor (Android.Graphics.Color.Argb (255, 52, 152, 219))
.SetThumbnailBorderColor (Android.Graphics.Color.Argb (255, 44, 62, 80))
.Build ();
// Show Document using PSPDFKit activity
var pspdfkitConfiguration = new PSPDFActivityConfiguration.Builder (Forms.Context, MainActivity.LicenseKey)
.ScrollDirection (PageScrollDirection.Horizontal)
.ShowPageNumberOverlay ()
.ShowThumbnailGrid ()
.ShowThumbnailBar ()
.ThumbnailBarThemeConfiguration (thumbnailBarThemeConfiguration)
.Build ();
if (!PSPDFKitGlobal.IsOpenableUri (Forms.Context, docUri)) {
ShowError ("This document uri cannot be opened \n " + docUri.ToString ());
} else {
try{
PSPDFAppCompatActivity.ShowDocument (Forms.Context, docUri, pspdfkitConfiguration);
}
catch(Exception ex){
var error = ex.StackTrace;
}
}
}