public static string GetUriFromPath(Context context, string path) { Android.Net.Uri uri = MediaStore.Audio.Media.GetContentUriForPath(path); string[] selection = { path }; ICursor cursor = context.ContentResolver.Query(uri, null, MediaStore.Audio.Media.InterfaceConsts.Data + "=?", selection, null); bool firstSuccess = cursor.MoveToFirst(); if (!firstSuccess) { return(path); } int idColumnIndex = cursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Id); long id = cursor.GetLong(idColumnIndex); cursor.Close(); if (!uri.ToString().EndsWith(id.ToString())) { return(uri + "/" + id); } return(uri.ToString()); }
//OnCreate protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); //Suche VideoView VideoView videoView1 = (VideoView)FindViewById(Resource.Id.videoView1); ProgressBar progressBar1 = (ProgressBar)FindViewById(Resource.Id.progressBar1); TextView textView1 = (TextView)FindViewById(Resource.Id.textView1); //Erzeuge MediaController MediaController mediaController = new MediaController(this, true); mediaController.SetAnchorView(videoView1); videoView1.SetMediaController(mediaController); videoView1.SetOnInfoListener(this); //übergebene Uri extrahieren Uri videoUri = this.Intent.Data; //Falls Uri vorhanden --> Starte Video if (string.IsNullOrEmpty(this.Intent.DataString) == false) { //ProgressBar anzeigen und videoView leeren textView1.Text = "Starte Videostream:\n" + videoUri.ToString(); progressBar1.Visibility = ViewStates.Visible; videoView1.Visibility = ViewStates.Gone; videoView1.Visibility = ViewStates.Visible; //Öffne Video Stream videoView1.SetVideoURI(videoUri); videoView1.Start(); } //Ansonste --> Starte Service else { //Überprüfe ob Service schon läuft //Starte Service Intent i = new Intent(this, typeof(MainService)); i.AddFlags(ActivityFlags.NewTask); this.StartService(i); } }
/* * Invoked when showNotificationButton is clicked. * Creates a new notification and sets metadata passed as arguments. */ public Notification CreateNotification(Priority priority, Category category, Uri contactUri) { var builder = new Notification.Builder(Activity) .SetContentTitle("Notification with other metadata") .SetSmallIcon(Resource.Drawable.ic_launcher_notification) .SetPriority((int)priority.priority) .SetCategory(category.ToString()) .SetContentText(string.Format("Category {0}, Priority {1}", category.ToString(), priority.ToString())); if (contactUri != null) { builder.AddPerson(contactUri.ToString()); Bitmap photoBitmap = LoadBitmapFromContactUri(contactUri); if (photoBitmap != null) { builder.SetLargeIcon(photoBitmap); } } return(builder.Build()); }
/// <summary> /// Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView. /// </summary> /// <param name="activity"> The host activity. </param> /// <param name="custom_tabs_intent"> a CustomTabsIntent to be used if Custom Tabs is available. </param> /// <param name="uri"> the Uri to be opened. </param> /// <param name="fallback"> a CustomTabFallback to be used if Custom Tabs is not available. </param> public /*static*/ void LaunchUrlWithCustomTabsOrFallback ( Activity a, CustomTabsIntent custom_tabs_intent, Android.Net.Uri u, ICustomTabFallback fallback ) { uri = u; activity = a; string packageName = PackageManagerHelper.GetPackageNameToUse(activity, uri.ToString()); //If we cant find a package name, it means theres no browser that supports //Chrome Custom Tabs installed. So, we fallback to the webview if (packageName == null) { if (fallback != null) { fallback.OpenUri(activity, uri); } } else { custom_tabs_intent.Intent.SetPackage(packageName); // direct call to CustomtTasIntent.LaunchUrl was ported from java samples and refactored // seems like API changed // // custom_tabs_intent.LaunchUrl(activity, uri); custom_tabs_activit_manager = new CustomTabsActivityManager(activity); custom_tabs_activit_manager.CustomTabsServiceConnected += custom_tabs_activit_manager_CustomTabsServiceConnected; service_bound = custom_tabs_activit_manager.BindService(); if (service_bound == false) { // No Packages that support CustomTabs } } return; }
public override void OnChange(bool selfChange, Android.Net.Uri uri) { lock (locker) { base.OnChange(selfChange, uri); if (uri.ToString().Contains(MediaStore.Images.Media.ExternalContentUri.ToString())) { ICursor cursor = null; try { cursor = contentResolver.Query(uri, new string[] { MediaStore.Images.Media.InterfaceConsts.DisplayName, MediaStore.Images.Media.InterfaceConsts.Data, MediaStore.Images.Media.InterfaceConsts.DateAdded, }, null, null, null); if (cursor != null && cursor.MoveToFirst()) { long now = Java.Lang.JavaSystem.CurrentTimeMillis() / 1000; do { string fileName = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.DisplayName)); string path = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data)); long dateAdded = cursor.GetLong(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.DateAdded)); if ((now - dateAdded) < 3 && this.lastUploadingFileName != fileName && fileName.ToLowerInvariant().Contains("screenshot")) { this.lastUploadingFileName = fileName; SmartPrintScreen.Upload(this.service, path); break; } } while (cursor.MoveToNext()); } } finally { if (cursor != null) { cursor.Close(); cursor.Dispose(); } } } } }
public async void ShareFile(string path, string fileType = "text/*") { int id = this.GetRequestId(); TaskCompletionSource <Android.Net.Uri> taskCompletionSource = new TaskCompletionSource <Android.Net.Uri>(id); MediaScannerConnection.ScanFile(this.context, new[] { path }, new[] { fileType }, new ShareFileCallbackImplementation(taskCompletionSource)); Android.Net.Uri uri = await taskCompletionSource.Task; byte[] data = this.OpenFile(uri.ToString()); Intent sharingIntent = new Intent(Intent.ActionSend); sharingIntent.SetType(fileType); sharingIntent.PutExtra(Intent.ExtraStream, Android.Net.Uri.Parse(path)); this.context.StartActivity(Intent.CreateChooser(sharingIntent, "Share Deck With")); }
private async Task <InnerData> GetRemoteJSONStringData(Uri requestUri) { InnerData responsePost = null; using (HttpClient client = new HttpClient()) { var response = await client.GetAsync(requestUri.ToString()); var json = await response.Content.ReadAsStringAsync(); MZFReddit redditDataObjects = JsonConvert.DeserializeObject <MZFReddit>(json); responsePost = redditDataObjects.data.children[0].data; } Intent broadcastMessage = new Intent(); broadcastMessage.PutExtra("key", responsePost.GetBundle()); broadcastMessage.SetAction(BROADCAST_RECEIVER_TAG); SendBroadcast(broadcastMessage); return(responsePost); }
private long GetFileSize() { Android.Database.ICursor cursor = null; try { cursor = context.ContentResolver.Query(url, null, null, null, null); if (cursor != null && cursor.MoveToFirst()) { var sizeIndex = cursor.GetColumnIndex(OpenableColumns.Size); if (cursor.IsNull(sizeIndex)) { return(0); //Unknown file size } return(long.Parse(cursor.GetString(sizeIndex))); } } finally { cursor?.Close(); } throw new Exception($"Unable to get file size for '{url.ToString()}'."); }
/** * Get the value of the data column for this Uri. This is useful for * MediaStore Uris, and other file-based ContentProviders. * * @param context The context. * @param uri The Uri to query. * @param selection (Optional) Filter used in the query. * @param selectionArgs (Optional) Selection arguments used in the query. * @return The value of the _data column, which is typically a file path. * @author paulburke */ private static string GetDataColumn(Context context, Uri uri, string selection, string[] selectionArgs) { ICursor cursor = null; string column = "_data"; string[] projection = { column }; try { cursor = context.ContentResolver.Query(uri, projection, selection, selectionArgs, null); if (cursor != null && cursor.MoveToFirst()) { #if DEBUG DatabaseUtils.DumpCursor(cursor); #endif int column_index = cursor.GetColumnIndexOrThrow(column); return(cursor.GetString(column_index)); } } catch { } finally { if (cursor != null) { cursor.Close(); } } return(uri.ToString()); }
/// <summary> /// Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView. /// </summary> /// <param name="activity"> The host activity. </param> /// <param name="custom_tabs_intent"> a CustomTabsIntent to be used if Custom Tabs is available. </param> /// <param name="uri"> the Uri to be opened. </param> /// <param name="fallback"> a CustomTabFallback to be used if Custom Tabs is not available. </param> public /*static*/ void LaunchUrlWithCustomTabsOrFallback ( Activity a, CustomTabsIntent custom_tabs_intent, string package_name_for_custom_tabs, Android.Net.Uri u, ICustomTabFallback fallback ) { uri = u; activity = a; bool fallback_neccessary = false; //If we cant find a package name, it means theres no browser that supports //Chrome Custom Tabs installed. So, we fallback to the webview if (package_name_for_custom_tabs == null) { fallback_neccessary = true; } else { custom_tabs_activity_manager = new CustomTabsActivityManager(this.activity); custom_tabs_activity_manager.BindService(package_name_for_custom_tabs); //custom_tabs_intent.Intent.SetPackage(package_name_for_custom_tabs); custom_tabs_session = custom_tabs_activity_manager.Session; custom_tabs_intent_builder = new CustomTabsIntent.Builder(custom_tabs_session); // direct call to CustomtTasIntent.LaunchUrl was ported from java samples and refactored // seems like API changed //------------------------------------------------------------------------------ //custom_tabs_intent.LaunchUrl(activity, uri); //return; //------------------------------------------------------------------------------ custom_tabs_activity_manager = new CustomTabsActivityManager(activity); custom_tabs_intent = custom_tabs_intent_builder.Build(); CustomTabsHelper.AddKeepAliveExtra(activity, custom_tabs_intent.Intent); custom_tabs_intent.LaunchUrl(activity, uri); custom_tabs_activity_manager.CustomTabsServiceConnected += // custom_tabs_activit_manager_CustomTabsServiceConnected delegate { System.Diagnostics.Debug.WriteLine("CustomTabsActivityManager.CustomTabsServiceConnected"); custom_tabs_activity_manager.LaunchUrl(uri.ToString()); System.Diagnostics.Debug.WriteLine("CustomTabsActivityManager.LaunchUrl"); return; } ; System.Diagnostics.Debug.WriteLine($"CustomTabsActivityManager.BindService({package_name_for_custom_tabs})"); service_bound = custom_tabs_activity_manager.BindService(package_name_for_custom_tabs); //custom_tabs_activity_manager.LaunchUrl(uri.ToString()); //------------------------------------------------------------------------------ if (service_bound == false) { System.Diagnostics.Debug.WriteLine($"FALLBACK: No Packages that support CustomTabs"); // No Packages that support CustomTabs fallback_neccessary = true; } } if (fallback_neccessary == true && fallback != null) { fallback.OpenUri(activity, uri); } return; }
internal static Task <Tuple <string, bool> > GetFileForUriAsync(Context context, Uri uri, bool isPhoto, bool saveToAlbum) { 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 { string[] proj = null; if ((int)Build.VERSION.SdkInt >= 22) { proj = new[] { MediaStore.MediaColumns.Data } } ; cursor = context.ContentResolver.Query(uri, proj, 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); } // If they don't follow the "rules", try to copy the file locally if (contentPath == null || !contentPath.StartsWith("file", StringComparison.InvariantCultureIgnoreCase)) { string fileName = null; try { fileName = Path.GetFileName(contentPath); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Unable to get file path name, using new unique " + ex); } var outputPath = GetOutputMediaFile(context, "temp", fileName, isPhoto, false); try { using (Stream input = context.ContentResolver.OpenInputStream(uri)) using (Stream output = File.Create(outputPath.Path)) input.CopyTo(output); contentPath = outputPath.Path; } catch (Java.IO.FileNotFoundException fnfEx) { // 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. System.Diagnostics.Debug.WriteLine("Unable to save picked file from disk " + fnfEx); } } tcs.SetResult(new Tuple <string, bool>(contentPath, false)); } } 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); }
private static string GetLocalPath(Uri uri) { return(new System.Uri(uri.ToString()).LocalPath); }
internal static Task <MediaPickedEventArgs> GetMediaFileAsync(Context context, int requestCode, string action, bool isPhoto, ref Uri path, Uri data, bool saveToAlbum) { Task <Tuple <string, bool> > pathFuture; 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(); string currentPath = path.Path; pathFuture = TryMoveFileAsync(context, data, path, isPhoto, false).ContinueWith(t => new Tuple <string, bool>(t.Result ? currentPath : null, false)); } else { pathFuture = TaskFromResult(new Tuple <string, bool>(path.Path, false)); } } else if (data != null) { originalPath = data.ToString(); path = data; pathFuture = GetFileForUriAsync(context, path, isPhoto, false); } else { pathFuture = TaskFromResult <Tuple <string, bool> >(null); } return(pathFuture.ContinueWith(t => { string resultPath = t.Result.Item1; var aPath = originalPath; if (resultPath != null && File.Exists(t.Result.Item1)) { var mf = new MediaFile(resultPath, () => { return File.OpenRead(resultPath); }, deletePathOnDispose: t.Result.Item2, dispose: (dis) => { if (t.Result.Item2) { try { File.Delete(t.Result.Item1); // We don't really care if this explodes for a normal IO reason. } catch (UnauthorizedAccessException uac) { System.Diagnostics.Debug.WriteLine("Unable to delete file, unauthorized " + uac.Message); } catch (DirectoryNotFoundException dnfe) { System.Diagnostics.Debug.WriteLine("Unable to delete file, not found: " + dnfe.Message); } catch (IOException ioe) { System.Diagnostics.Debug.WriteLine("Unable to delete file, io exception: " + ioe.Message); } } }, albumPath: aPath); return new MediaPickedEventArgs(requestCode, false, mf); } else { return new MediaPickedEventArgs(requestCode, new MediaFileNotFoundException(originalPath)); } })); }
internal static Task <MediaPickedEventArgs> GetMediaFileAsync(Context context, int requestCode, string action, bool isPhoto, ref Uri path, Uri data, bool saveToAlbum) { Task <Tuple <string, bool> > pathFuture; 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(); string currentPath = path.Path; pathFuture = TryMoveFileAsync(context, data, path, isPhoto, saveToAlbum).ContinueWith(t => new Tuple <string, bool>(t.Result ? currentPath : null, false)); } else { pathFuture = TaskFromResult(new Tuple <string, bool>(path.Path, false)); } } else if (data != null) { originalPath = data.ToString(); path = data; pathFuture = GetFileForUriAsync(context, path, isPhoto, saveToAlbum); } else { pathFuture = TaskFromResult <Tuple <string, bool> >(null); } return(pathFuture.ContinueWith(t => { string resultPath = t.Result.Item1; if (resultPath != null && File.Exists(t.Result.Item1)) { string aPath = null; if (saveToAlbum) { aPath = resultPath; try { var f = new Java.IO.File(resultPath); //MediaStore.Images.Media.InsertImage(context.ContentResolver, // f.AbsolutePath, f.Name, null); try { Android.Media.MediaScannerConnection.ScanFile(context, new [] { f.AbsolutePath }, null, context as MediaPickerActivity); ContentValues values = new ContentValues(); values.Put(MediaStore.Images.Media.InterfaceConsts.Title, Path.GetFileNameWithoutExtension(f.AbsolutePath)); values.Put(MediaStore.Images.Media.InterfaceConsts.Description, string.Empty); values.Put(MediaStore.Images.Media.InterfaceConsts.DateTaken, Java.Lang.JavaSystem.CurrentTimeMillis()); values.Put(MediaStore.Images.ImageColumns.BucketId, f.ToString().ToLowerInvariant().GetHashCode()); values.Put(MediaStore.Images.ImageColumns.BucketDisplayName, f.Name.ToLowerInvariant()); values.Put("_data", f.AbsolutePath); var cr = context.ContentResolver; cr.Insert(MediaStore.Images.Media.ExternalContentUri, values); } catch (Exception ex1) { Console.WriteLine("Unable to save to scan file: " + ex1); } var contentUri = Uri.FromFile(f); var mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile, contentUri); context.SendBroadcast(mediaScanIntent); } catch (Exception ex2) { Console.WriteLine("Unable to save to gallery: " + ex2); } } var mf = new MediaFile(resultPath, () => { return File.OpenRead(resultPath); }, deletePathOnDispose: t.Result.Item2, dispose: (dis) => { if (t.Result.Item2) { try { File.Delete(t.Result.Item1); // We don't really care if this explodes for a normal IO reason. } catch (UnauthorizedAccessException) { } catch (DirectoryNotFoundException) { } catch (IOException) { } } }, albumPath: aPath); return new MediaPickedEventArgs(requestCode, false, mf); } else { return new MediaPickedEventArgs(requestCode, new MediaFileNotFoundException(originalPath)); } })); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // get Broadcast Receiver mBroadcasReceiver = new MyBroadcastReceiver(this); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); mWebView = FindViewById <WebView>(Resource.Id.webView); mWebView.Settings.JavaScriptEnabled = true; mWebView.Settings.SetGeolocationEnabled(true); //mWebView.SetWebViewClient(new MyWebViewClient()); //Somehow is not necessary mWebView.SetWebChromeClient(new MyWebChromeClient(this)); mWebView.AddJavascriptInterface(new WebAppInterface(this), "Android"); // try set cookies try { var firebaseToken = FirebaseInstanceId.Instance.Token; if (firebaseToken != null) { String cookieFirebaseToken = "firebaseToken=" + firebaseToken; CookieManager.Instance.SetCookie(MainActivity.DOMAIN, cookieFirebaseToken); } } catch (Exception e) { Log.Error(TAG, e.ToString()); } // the intent stuff // Get intent, action and MIME type // seeAus //Intent intent = getIntent(); //String action = intent.getAction(); //String type = intent.getType(); Intent intent = Intent; String action = intent.Action; String type = intent.Type; if (Intent.ActionSend.Equals(action) && type != null && "text/plain".Equals(type)) { String extraText = intent.GetStringExtra(Intent.ExtraText); // für nzz app und vieles mehr (eigentlich sollte es eine weiche geben -> ev auch einfach beitrag mit diesem text) String[] urlArray = ExtractLinks(extraText); if (urlArray[0] != null) { // PsProcess[] processArray = new PsProcess[] { new PsProcess("xbyuri", "/checkuri", urlArray[0], null) }; // String url = MainActivity.DOMAIN + "/checkuri?p=" + JsonConvert.SerializeObject(processArray); String url = MainActivity.DOMAIN + "/startprocess?name=xbyuri&inputValue=" + urlArray[0]; mWebView.LoadUrl(url); } } else if (Intent.ActionSend.Equals(action) && type != null && type.StartsWith("image/")) { // ein neues image wird erstellt... - ohne existierende prozessid // neu - nein, bei einem image intent laden wir die seite bewusst nicht! // denn diese seite stört immer den image upload! Boolean extraOk = true; Android.Net.Uri imageUri = (Android.Net.Uri)intent.GetParcelableExtra(Intent.ExtraStream); if (imageUri.ToString() == "" || imageUri.ToString() == null) { extraOk = false; } String cookie = this.GetCookie(MainActivity.DOMAIN, "connect.sid"); if (cookie == null) { extraOk = false; } if (extraOk == true) { mWebView.LoadUrl("about:blank"); Intent i = new Intent(this, typeof(ImgCreateActivity)); i.PutExtra("cookie", cookie); i.PutExtra("imageUri", imageUri.ToString()); // start the process // PsProcess[] processArray = new PsProcess[] { new PsProcess("image", "/x-create", null, null) }; // i.PutExtra("processArray", JsonConvert.SerializeObject(processArray)); this.StartActivityForResult(i, IMG_CREATE_REQUEST); } } else { // Load url to be rendered on WebView String path = intent.GetStringExtra("path"); String url = MainActivity.DOMAIN; if (path != null) { url += path; } if (Intent.ActionView.Equals(action)) { Android.Net.Uri data = intent.Data; if (data != null) { url = data.ToString(); } } mWebView.LoadUrl(url); } }
/** * Get a file path from a Uri. This will get the the path for Storage Access * Framework Documents, as well as the _data field for the MediaStore and * other file-based ContentProviders.<br> * <br> * Callers should check whether the path is local before assuming it * represents a local file. * * @param context The context. * @param uri The Uri to query. * @see #isLocal(string) * @see #getFile(Context, Uri) * @author paulburke */ public static string GetPath(Context context, Uri uri) { #if DEBUG Log.Debug("FilePathHelper -", "Authority: " + uri.Authority + ", Fragment: " + uri.Fragment + ", Port: " + uri.Port + ", Query: " + uri.Query + ", Scheme: " + uri.Scheme + ", Host: " + uri.Host + ", Segments: " + uri.PathSegments.ToString() ); #endif // DocumentProvider if (DocumentsContract.IsDocumentUri(context, uri)) { // LocalStorageProvider if (IsLocalStorageDocument(uri)) { // The path is the id return(DocumentsContract.GetDocumentId(uri)); } // ExternalStorageProvider else if (IsExternalStorageDocument(uri)) { string docId = DocumentsContract.GetDocumentId(uri); string[] split = docId.Split(':'); string type = split[0]; if ("primary".ToLower() == type.ToLower()) { return(Android.OS.Environment.ExternalStorageDirectory + "/" + split[1]); } else { try { var path = $"/storage/{type}/{split[1]}"; // Test if this is working var file = new Java.IO.File(path); if (!file.Exists()) { throw new NonPrimaryExternalStorageNotSupportedException(); } return(path); } catch (Exception) { return(uri.ToString()); } } // TODO handle non-primary volumes } // DownloadsProvider else if (IsDownloadsDocument(uri)) { string id = DocumentsContract.GetDocumentId(uri); if (id.Length > 4 && id.Substring(0, 4) == "raw:") { return(id.Substring(4)); } else { Uri contentUri = ContentUris.WithAppendedId(Uri.Parse("content://downloads/public_downloads"), long.Parse(id)); return(GetDataColumn(context, contentUri, null, null)); } } // MediaProvider else if (IsMediaDocument(uri)) { string docId = DocumentsContract.GetDocumentId(uri); string[] split = docId.Split(':'); string type = split[0]; Uri contentUri = null; if ("image" == type) { contentUri = MediaStore.Images.Media.ExternalContentUri; } else if ("video" == type) { contentUri = MediaStore.Video.Media.ExternalContentUri; } else if ("audio" == type) { contentUri = MediaStore.Audio.Media.ExternalContentUri; } string selection = "_id=?"; string[] selectionArgs = new string[] { split[1] }; return(GetDataColumn(context, contentUri, selection, selectionArgs)); } } // MediaStore (and general) else if ("content".ToLower() == uri.Scheme.ToLower()) { // Return the remote address if (IsGooglePhotosUri(uri)) { return(uri.LastPathSegment); } return(GetDataColumn(context, uri, null, null)); } // File else if ("file".ToLower() == uri.Scheme.ToLower()) { return(uri.Path); } return(uri.ToString()); }
/* * Invoked when showNotificationButton is clicked. * Creates a new notification and sets metadata passed as arguments. */ public Notification CreateNotification(Priority priority, Category category, Uri contactUri) { var builder = new Notification.Builder (Activity) .SetContentTitle ("Notification with other metadata") .SetSmallIcon (Resource.Drawable.ic_launcher_notification) .SetPriority ((int)priority.priority) .SetCategory (category.ToString ()) .SetContentText(string.Format("Category {0}, Priority {1}",category.ToString(),priority.ToString())); if (contactUri != null) { builder.AddPerson (contactUri.ToString ()); Bitmap photoBitmap = LoadBitmapFromContactUri (contactUri); if (photoBitmap != null) builder.SetLargeIcon (photoBitmap); } return builder.Build (); }