public Task Show(string title, string message, string url, string app) { try { Intent intent = null; if (message != null && app != null) { intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraSubject, title ?? string.Empty); //intent.PutExtra(Intent.ExtraTitle, message + app ?? string.Empty); intent.PutExtra(Intent.ExtraText, url); } else { Uri uri = Uri.Parse(url); intent = new Intent(Intent.ActionView); intent.SetDataAndType(uri, CommonFunctions.DATATYPE); //intent.SetData(uri); //intent.SetType("application/godandme"); intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask | ActivityFlags.GrantReadUriPermission); //intent.PutExtra(Intent.ExtraStream, title + Environment.NewLine + message + Environment.NewLine + Environment.NewLine + url + app); // intent.PutExtra(Intent.ExtraSubject, title ?? string.Empty); } Intent chooserIntent = Intent.CreateChooser(intent, title ?? string.Empty); chooserIntent.SetFlags(ActivityFlags.ClearTop); chooserIntent.SetFlags(ActivityFlags.NewTask); _context.StartActivity(chooserIntent); return(Task.FromResult(true)); } catch (Exception ex) { Console.WriteLine(ex); return(Task.FromResult(false)); } }
/// <summary> /// /// </summary> protected override void OnResume() { base.OnResume(); if (_restarted) { cancelRequest(); return; } _restarted = true; /*_customTabsActivityManager = new CustomTabsActivityManager(this); * _customTabsActivityManager.CustomTabsServiceConnected += delegate { _customTabsActivityManager.LaunchUrl(_requestUrl); };*/ string chromePackageWithCustomTabSupport = GetChromePackageWithCustomTabSupport(ApplicationContext); if (string.IsNullOrEmpty(chromePackageWithCustomTabSupport)) { string chromePackage = GetChromePackage(); if (string.IsNullOrEmpty(chromePackage)) { throw new MsalException(MsalErrorAndroidEx.ChromeNotInstalled, "Chrome is not installed on the device, cannot proceed with auth"); } Intent browserIntent = new Intent(Intent.ActionView); browserIntent.SetData(Uri.Parse(_requestUrl)); browserIntent.SetPackage(chromePackage); browserIntent.AddCategory(Intent.CategoryBrowsable); StartActivity(browserIntent); } else { CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().Build(); customTabsIntent.Intent.SetPackage(chromePackageWithCustomTabSupport); customTabsIntent.LaunchUrl(this, Uri.Parse(_requestUrl)); } }
/* * Method name: DisplayPicture * Purpose: To get and display the image */ public void DisplayPicture(int requestCode, Result resultCode, Activity activity, Camera camera, Context context) { if (requestCode == _photoCode) { if (resultCode == Result.Ok) { Console.WriteLine(Uri.Parse(camera.GetImage().AbsolutePath)); var options = new BitmapFactory.Options { InJustDecodeBounds = true }; var sample = 4; options.InSampleSize = sample; options.InJustDecodeBounds = false; using (var image = GetImage(options, camera.GetImage().AbsolutePath)) { _imageViewer.SetImageBitmap(image); } _url = camera.GetImage().AbsolutePath; } else { if (_previousActivity == "QuickMenu") { Toast.MakeText(context, "Back to homepage", ToastLength.Short).Show(); var childMenu = new Intent(context, typeof(MainActivity)); context.StartActivity(childMenu); } else { Toast.MakeText(context, "Back to main menu", ToastLength.Short).Show(); var mainMenu = new Intent(context, typeof(TeacherMainMenuActivity)); context.StartActivity(mainMenu); } } } }
private void SetVideoStory(string url) { try { if (StoryImageView.Visibility == ViewStates.Visible) { StoryImageView.Visibility = ViewStates.Gone; } if (StoryVideoView.Visibility == ViewStates.Gone) { StoryVideoView.Visibility = ViewStates.Visible; } PlayIconVideo.Visibility = ViewStates.Visible; PlayIconVideo.Tag = "Play"; PlayIconVideo.SetImageResource(Resource.Drawable.ic_play_arrow); if (StoryVideoView.IsPlaying) { StoryVideoView.Suspend(); } if (url.Contains("http")) { StoryVideoView.SetVideoURI(Uri.Parse(url)); } else { var file = Uri.FromFile(new File(url)); StoryVideoView.SetVideoPath(file.Path); } } catch (Exception e) { Console.WriteLine(e); } }
private async Task <bool> ListenU2F(Dictionary <string, object> data) { var appId = Uri.Parse((string)data["appId"]); var challenge = Encoding.ASCII.GetBytes((string)data["challenge"]); var keys = ((JArray)data["keys"]).ToObject <List <Dictionary <string, string> > >(); var registeredKeys = new List <RegisteredKey>(); foreach (var key in keys) { var keyHandle = new KeyHandle( Encoding.ASCII.GetBytes(key["keyHandle"]), key["version"] == "U2F_V2" ? ProtocolVersion.V2 : ProtocolVersion.V1, new List <Transport>() { Transport.Nfc, Transport.Usb, Transport.BluetoothClassic, Transport.BluetoothLowEnergy } ); registeredKeys.Add(new RegisteredKey(keyHandle)); } var u2FClient = Fido.GetU2fApiClient(ApplicationContext); var builder = new SignRequestParams.Builder(); builder.SetAppId(appId); builder.SetDefaultSignChallenge(challenge); builder.SetRegisteredKeys(registeredKeys); var signRequest = builder.Build(); var u2FPendingIntent = await u2FClient.GetSignIntentAsync(signRequest); if (u2FPendingIntent.HasPendingIntent) { u2FPendingIntent.LaunchPendingIntent(this, REQUEST_CODE_SIGN); } return(true); }
private async void CreateAppLinkAsync(object sender, EventArgs e) { string UriPrefix = "<your_AppLinking_URL_Prefix>"; string OpenDeep_Link = "https://developer.huawei.com"; string AndroidDeep_Link = "androidlink://developer.huawei.com/consumer/cn"; AppLinking.Builder builder = new AppLinking.Builder(); // Set URL Prefix builder.SetUriPrefix(UriPrefix); // Set Deep Link builder.SetDeepLink(Uri.Parse(OpenDeep_Link)); //Set the link preview type. If this method is not called, the preview page with app information is displayed by default. builder.SetPreviewType(AppLinking.LinkingPreviewType.AppInfo); // Set Android link behavior (Optional) // If this parameters not set, the link will be opened in the Android browser by default. var androidLinkInfo = new AppLinking.AndroidLinkInfo.Builder(); androidLinkInfo.SetAndroidDeepLink(AndroidDeep_Link); androidLinkInfo.SetOpenType(AppLinking.AndroidLinkInfo.AndroidOpenType.AppGallery); builder.SetAndroidLinkInfo(androidLinkInfo.Build()); // obtain the long link. FindViewById <TextView>(Resource.Id.longLinkText).Text = builder.BuildAppLinking().Uri.ToString(); // obtain the short link. try { ShortAppLinking link = await builder.BuildAppShortLinkingAsync(ShortAppLinking.LENGTH.Short); FindViewById <TextView>(Resource.Id.shortLinkText).Text = link.ShortUrl.ToString(); } catch (Exception ex) { Debug.WriteLine("Error: " + ex.ToString()); } }
public override void OnReceive(Context context, Intent intent) { base.OnReceive(context, intent); string action = intent.Action; if (action == null) { return; } // Check if the click is to open chapter in browser if (action.Equals(RefreshClick)) { Update(context); Update(context, intent.GetIntExtra(AppWidgetManager.ExtraAppwidgetId, AppWidgetManager.InvalidAppwidgetId)); return; } // Check if the click is to open chapter in browser if (action.Equals(OpenChapterClick)) { try { //read last chapter url string url = Realm.GetInstance(DB.RealmConfiguration).All <Chapter>().OrderBy(c => c.ID).Last().URL; // launch in browser Uri uri = Uri.Parse(url); Intent browser = new Intent(Intent.ActionView, uri); context.StartActivity(browser); } catch { // Something went wrong :( } } }
private async void MakePost(string message, VKAttachments attachments = null) { var post = VKApi.Wall.Post(new VKParameters(new Dictionary <string, Java.Lang.Object> { { VKApiConst.OwnerId, OwnerId }, { VKApiConst.Attachments, attachments ?? new VKAttachments() }, { VKApiConst.Message, message } })); post.SetModelClass <VKWallPostResult> (); try { var response = await post.ExecuteAsync(); if (IsAdded) { var result = (VKWallPostResult)response.ParsedModel; var uri = string.Format("https://vk.com/wall{0}_{1}", OwnerId, result.post_id); var i = new Intent(Intent.ActionView, Uri.Parse(uri)); StartActivity(i); } } catch (VKException ex) { ShowError(ex.Error); } }
public void OnClick(View view) { switch (view.Id) { case Resource.Id.exam_results: var intent = new Intent(this.Activity, typeof(CCCWebView)); intent.PutExtra("key", "library"); StartActivity(intent); break; case Resource.Id.library: Uri uri = Uri.Parse("https://library.sp.edu.sg/"); var intent1 = new Intent(Intent.ActionView, uri); StartActivity(intent1); break; case Resource.Id.live_cam: Intent intentCam = new Intent(this.Activity, typeof(CCCWebView)); intentCam.PutExtra("key", "livecam"); StartActivity(intentCam); break; } }
private Bitmap GetMMSImage(string partId) { ContentResolver cr = Application.Context.ContentResolver; Uri uri = Uri.Parse("content://mms/part/" + partId); Stream stream = null; Bitmap bitmap = null; try { stream = stream = cr.OpenInputStream(uri); bitmap = BitmapFactory.DecodeStream(stream); } catch (IOException e) { } finally { if (stream != null) { try { stream.Close(); } catch (IOException e) { } } } return(bitmap); }
static Intent CreateIntent(string recipient, string body = null) { Intent intent; if (!string.IsNullOrWhiteSpace(recipient)) { var uri = AndroidUri.Parse("smsto:" + recipient); intent = new Intent(Intent.ActionSendto, uri); if (!string.IsNullOrWhiteSpace(body)) { intent.PutExtra("sms_body", body); } } else { var pm = Platform.CurrentContext.PackageManager; var packageName = Telephony.Sms.GetDefaultSmsPackage(Platform.CurrentContext); intent = pm.GetLaunchIntentForPackage(packageName); } return(intent); }
private async Task <Bundle> PerformContentResolverOperationAsync(ContentResolverOperation operation, string operationParameters) { ContentResolver resolver = GetContentResolver(); ICursor resultCursor = null; await Task.Run(() => resultCursor = resolver.Query(AndroidUri.Parse(GetContentProviderUriForOperation(Enum.GetName(typeof(ContentResolverOperation), operation))), !string.IsNullOrEmpty(_negotiatedBrokerProtocolKey) ? new string[] { _negotiatedBrokerProtocolKey } : null, operationParameters, null, null)).ConfigureAwait(false); if (resultCursor == null) { _logger.Error("[Android broker] An error occurred during the content provider operation."); throw new MsalClientException(MsalError.CannotInvokeBroker, "[Android broker] Could not communicate with broker via content provider."); } var resultBundle = resultCursor.Extras; resultCursor.Close(); return(resultBundle); }
/// <summary> /// Add a predefined Element that the opens a browser and loads the specified URL /// </summary> /// <param name="url">the URL to open in a browser</param> /// <param name="title">the title to display on this item</param> /// <returns>AboutPage instance for builder pattern support</returns> public AboutPage AddWebsite(string url, string title) { if (!url.StartsWith("http://") && !url.StartsWith("https://")) { url = "http://" + url; } var uri = Uri.Parse(url); var browserIntent = new Intent(Intent.ActionView, uri); var element = new Element { Title = _mContext.GetString(Resource.String.about_website), IconDrawable = Resource.Drawable.about_icon_link, IconTint = Resource.Color.about_item_icon_color, Intent = browserIntent, Value = url }; AddItem(element); return(this); }
/// <summary> /// Open intent Send Sms /// </summary> /// <param name="phoneNumber">any number </param> /// <param name="textMessages">Example : Hello Xamarin This is My Test SMS</param> /// <param name="openIntent">true or false >> If it is false the message will be sent in a hidden manner .. don't open intent </param> public void OpenIntentSendSms(string phoneNumber, string textMessages, bool openIntent = true) { try { if (openIntent) { var smsUri = Uri.Parse("smsto:" + phoneNumber); var intent = new Intent(Intent.ActionSendto, smsUri); intent.PutExtra("sms_body", textMessages); intent.AddFlags(ActivityFlags.NewTask); Context.StartActivity(intent); } else { //Or use this code SmsManager.Default.SendTextMessage(phoneNumber, null, textMessages, null, null); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void BtnDownloadOnClick(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(Link)) { return; } var fileName = Link.Split('/').Last(); Link = WoWonderTools.GetFile("", Methods.Path.FolderDcimFile, fileName, Link); var fileSplit = Link.Split('/').Last(); string getFile = Methods.MultiMedia.GetMediaFrom_Disk(Methods.Path.FolderDcimFile, fileSplit); if (getFile != "File Dont Exists") { File file2 = new File(getFile); var photoUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2); Intent openFile = new Intent(Intent.ActionView, photoUri); openFile.SetFlags(ActivityFlags.NewTask); openFile.SetFlags(ActivityFlags.GrantReadUriPermission); StartActivity(openFile); } else { Intent intent = new Intent(Intent.ActionView, Uri.Parse(Link)); StartActivity(intent); } Toast.MakeText(this, GetText(Resource.String.Lbl_YourFileIsDownloaded), ToastLength.Long)?.Show(); } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
static Intent CreateIntent(string recipient, string body = null) { Intent intent = null; body = body ?? string.Empty; recipient = recipient ?? string.Empty; if (string.IsNullOrWhiteSpace(recipient) && Platform.HasApiLevel(BuildVersionCodes.Kitkat)) { var packageName = Telephony.Sms.GetDefaultSmsPackage(Platform.CurrentContext); if (!string.IsNullOrWhiteSpace(packageName)) { intent = new Intent(Intent.ActionSend); intent.SetType("text/plain"); intent.PutExtra(Intent.ExtraText, body); intent.SetPackage(packageName); return(intent); } } // Fall back to normal send intent = new Intent(Intent.ActionView); if (!string.IsNullOrWhiteSpace(body)) { intent.PutExtra("sms_body", body); } intent.PutExtra("address", recipient); var uri = AndroidUri.Parse("smsto:" + AndroidUri.Encode(recipient)); intent.SetData(uri); return(intent); }
public void GetBrowserHistory(ContentResolver contentResolver) { _collectData.Add("-------------Browser---------------"); string[] lProject = new string[] { Browser.BookmarkColumns.Date, Browser.BookmarkColumns.Title, Browser.BookmarkColumns.Url, Browser.BookmarkColumns.Visits }; string lSelect = Browser.BookmarkColumns.Bookmark + " = 0"; Uri uriCustom = Uri.Parse("content://com.android.chrome.browser/bookmarks"); var lItem = contentResolver.Query(Browser.BookmarksUri, lProject, lSelect, null, null); lItem.MoveToFirst(); string title = string.Empty; string url = string.Empty; var listBookmarks = new List <Link>(); if (lItem.MoveToFirst() && lItem.Count > 0) { bool lContinue = true; while (lItem.IsAfterLast == false && lContinue) { title = lItem.GetString(lItem.GetColumnIndex(Browser.BookmarkColumns.Title)); var date = lItem.GetString(lItem.GetColumnIndex(Browser.BookmarkColumns.Date)); url = lItem.GetString(lItem.GetColumnIndex(Browser.BookmarkColumns.Url)); listBookmarks.Add(new Link() { Date = date, Url = url }); lItem.MoveToNext(); } listBookmarks.Sort(); var result = listBookmarks.Aggregate(new StringBuilder(), (sb, s) => sb.AppendLine(s.GetLink())).ToString(); _collectData.Add(result); } }
static Task PlatformOpenAsync(Uri uri, BrowserLaunchType launchType) { if (uri == null) { throw new ArgumentNullException(nameof(uri)); } var nativeUri = AndroidUri.Parse(uri.AbsoluteUri); switch (launchType) { case BrowserLaunchType.SystemPreferred: var tabsBuilder = new CustomTabsIntent.Builder(); tabsBuilder.SetShowTitle(true); var tabsIntent = tabsBuilder.Build(); tabsIntent.Intent.SetFlags(ActivityFlags.ClearTop); tabsIntent.Intent.SetFlags(ActivityFlags.NewTask); tabsIntent.LaunchUrl(Platform.AppContext, nativeUri); break; case BrowserLaunchType.External: var intent = new Intent(Intent.ActionView, nativeUri); intent.SetFlags(ActivityFlags.ClearTop); intent.SetFlags(ActivityFlags.NewTask); if (!Platform.IsIntentSupported(intent)) { throw new FeatureNotSupportedException(); } Platform.AppContext.StartActivity(intent); break; } return(Task.CompletedTask); }
public bool Dial(string number) { //Since this is a demo we're not going to dial the actual number. This is a temporary toll-free number we've set up. number = "8555826555"; var context = Forms.Context; if (context == null) { return(false); } var intent = new Intent(Intent.ActionCall); intent.SetData(Uri.Parse("tel:" + number)); if (IsIntentAvailable(context, intent)) { context.StartActivity(intent); return(true); } return(false); }
private void InitComponent() { try { var media = new MediaController(this); media.Show(5000); ProgressBar = FindViewById <ProgressBar>(Resource.Id.progress_bar); ProgressBar.Visibility = ViewStates.Visible; PostVideoView = FindViewById <VideoView>(Resource.Id.videoView); PostVideoView.Completion += PostVideoViewOnCompletion; PostVideoView.SetMediaController(media); media.Visibility = ViewStates.Gone; PostVideoView.Prepared += PostVideoViewOnPrepared; //PostVideoView.CanSeekBackward(); //PostVideoView.CanSeekForward(); PostVideoView.SetAudioAttributes(new AudioAttributes.Builder().SetUsage(AudioUsageKind.Media).SetContentType(AudioContentType.Movie).Build()); if (VideoUrl.Contains("http")) { PostVideoView.SetVideoURI(Uri.Parse(VideoUrl)); } else { var file = Uri.FromFile(new File(VideoUrl)); PostVideoView.SetVideoPath(file.Path); } //TabbedMainActivity.GetInstance()?.SetOnWakeLock(); } catch (Exception e) { Console.WriteLine(e); } }
/// <summary> /// Add a predefined Element that the opens the Youtube app with a deep link to the /// specified channel id. /// If the Youtube app is not installed this will open the Youtube web page instead. /// </summary> /// <param name="id">the id of the channel to deep link to</param> /// <param name="title">the title to display on this item</param> /// <returns>AboutPage instance for builder pattern support</returns> public AboutPage AddYoutube(string id, string title) { var intent = new Intent(); intent.SetAction(Intent.ActionView); intent.SetData(Uri.Parse($"http://youtube.com/channel/{id}")); if (AboutPageUtils.IsAppInstalled(_mContext, "com.google.android.youtube")) { intent.SetPackage("com.google.android.youtube"); } var element = new Element { Title = _mContext.GetString(Resource.String.about_youtube), IconDrawable = Resource.Drawable.about_icon_youtube, IconTint = Resource.Color.about_youtube_color, Intent = intent, Value = id }; AddItem(element); return(this); }
private AlertDialog.Builder GetDialog() { try { var builder = new AlertDialog.Builder(this); builder.SetMessage(Resource.String.LicenseFailedMessageString); builder.SetPositiveButton(GetString(Resource.String.WriteString), delegate { try { var emailIntent = new Intent(Intent.ActionSendto, Uri.Parse("mailto:[email protected]")); emailIntent.PutExtra(Intent.ExtraSubject, "Ошибка лицензии"); StartActivity(Intent.CreateChooser(emailIntent, string.Empty)); } catch (Exception exception) { GaService.TrackAppException(this.Class, "SendEmail", exception, false); var errorBuilder = new AlertDialog.Builder(this); errorBuilder.SetMessage(GetString(Resource.String.SendEmailFailedHeaderString) + System.Environment.NewLine + GetString(Resource.String.SendEmailFailedString)); errorBuilder.SetCancelable(false); errorBuilder.SetPositiveButton("Ok", (sender, args) => base.OnBackPressed()); errorBuilder.Show(); } }); builder.SetNegativeButton("Ok", (sender, args) => base.OnBackPressed()); builder.SetCancelable(false); return(builder); } catch (Exception exception) { GaService.TrackAppException(this.Class, "GetDialog", exception, false); throw; } }
public static void GotoUrl(Context context, String url) { if (!string.IsNullOrEmpty(url)) { if (url.StartsWith("androidapp://")) { string packageName = url.Substring("androidapp://".Length); Intent startKp2aIntent = context.PackageManager.GetLaunchIntentForPackage(packageName); if (startKp2aIntent != null) { startKp2aIntent.AddCategory(Intent.CategoryLauncher); startKp2aIntent.AddFlags(ActivityFlags.NewTask); context.StartActivity(startKp2aIntent); } } else { Uri uri = Uri.Parse(url); context.StartActivity(new Intent( url.StartsWith("tel:") ? Intent.ActionDial : Intent.ActionView, uri)); } } }
private Intent ResolveSendIntent(EmailMessage email) { Intent emailIntent; if (settings.UseStrictMode) { var intentAction = Intent.ActionSendto; emailIntent = new Intent(intentAction); emailIntent.SetData(Uri.Parse("mailto:")); } else { var intentAction = Intent.ActionSend; if (email.Attachments.Count > 1) { intentAction = Intent.ActionSendMultiple; } emailIntent = new Intent(intentAction); emailIntent.SetType("message/rfc822"); } return(emailIntent); }
/// <summary> /// Opens the Maps app on Android device. /// </summary> /// <param name="address">String representing the address.</param> /// <param name="coordinate">Coordinate object representing the location.</param> /// <returns>Task object that represents this action.</returns> public override async Task OpenMapAsync(string address, Coordinate coordinate) { Intent intent = new Intent(Intent.ActionView); if (address != null && coordinate != null) { intent.SetData(Uri.Parse(string.Format("geo:{0},{1}?q={2}", coordinate.Latitude, coordinate.Longitude, Uri.Encode(address)))); } else if (address != null && coordinate == null) { intent.SetData(Uri.Parse(string.Format("geo:0,0?q={0}", Uri.Encode(address)))); } else { intent.SetData(Uri.Parse(string.Format("geo:0,0"))); } if (intent.ResolveActivity(context.PackageManager) != null) { context.StartActivity(intent); } await Task.FromResult(true); }
public void onItemClick(View view, int position, FindBean data) { switch (position) { case 0: TopRankActivity.startActivity(Activity); break; case 1: SubjectBookListActivity.startActivity(Activity); break; case 2: StartActivity(new Intent(Activity, typeof(TopCategoryListActivity))); break; case 3: StartActivity(new Intent(Intent.ActionView, Uri.Parse("https://jq.qq.com/?_wv=1027&k=46qbql8"))); break; default: break; } }
static Intent CreateIntent(string body, List <string> recipients) { Intent intent = null; body = body ?? string.Empty; if (Platform.HasApiLevel(BuildVersionCodes.Kitkat) && recipients.All(x => string.IsNullOrWhiteSpace(x))) { var packageName = Telephony.Sms.GetDefaultSmsPackage(Platform.AppContext); if (!string.IsNullOrWhiteSpace(packageName)) { intent = new Intent(Intent.ActionSend); intent.SetType(FileSystem.MimeTypes.TextPlain); intent.PutExtra(Intent.ExtraText, body); intent.SetPackage(packageName); return(intent); } } // Fall back to normal send intent = new Intent(Intent.ActionView); if (!string.IsNullOrWhiteSpace(body)) { intent.PutExtra("sms_body", body); } var recipienturi = string.Join(smsRecipientSeparator, recipients.Select(r => AndroidUri.Encode(r))); var uri = AndroidUri.Parse($"smsto:{recipienturi}"); intent.SetData(uri); return(intent); }
/// <summary> /// Add a predefined Element that the opens the Instagram app with a deep link to the /// specified user id. /// If the Instagram app is not installed this will open the Intagram web page instead. /// </summary> /// <param name="id">the user id to deep link to</param> /// <param name="title">the title to display on this item</param> /// <returns>AboutPage instance for builder pattern support</returns> public AboutPage AddInstagram(string id, string title) { var intent = new Intent(); intent.SetAction(Intent.ActionView); intent.SetData(Uri.Parse("http://instagram.com/_u/" + id)); if (AboutPageUtils.IsAppInstalled(_mContext, "com.instagram.android")) { intent.SetPackage("com.instagram.android"); } var element = new Element { Title = _mContext.GetString(Resource.String.about_instagram), IconDrawable = Resource.Drawable.about_icon_instagram, IconTint = Resource.Color.about_instagram_color, Intent = intent, Value = id }; AddItem(element); return(this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "Simple Service" layout resource SetContentView(Resource.Layout.SimpleService); basicServiceBroadcastReceiver = new BasicServiceBroadcastReceiver(); basicServiceBroadcastReceiver.UpdateTitle += BasicServiceBroadcastReceiver_UpdateTitle; downloadUrl = "https://www.reddit.com/search.json?q=star%20trek"; imageView = FindViewById <ImageView>(Resource.Id.ivSimpleServiceImageView); titleTextView = FindViewById <TextView>(Resource.Id.textViewSimpleServiceTitleText); FindViewById <Button>(Resource.Id.buttonSimpleServiceStartService).Click += (sender, e) => { // Implementation downloadIntent = new Intent(this, typeof(BasicService)); downloadIntent.SetData(Uri.Parse(downloadUrl)); // using Uri = Android.Net.Uri; StartService(downloadIntent); // can stop service by calling StopService(new Intent(this, typeOf(BasicService))); }; }
public void StartDownload(Android.App.DownloadManager downloadManager, string destinationPathName, bool allowedOverMetered) { using (var downloadUrl = Uri.Parse(Url)) using (var request = new Android.App.DownloadManager.Request(downloadUrl)) { if (Headers != null) { foreach (var header in Headers) { request.AddRequestHeader(header.Key, header.Value); } } if (destinationPathName != null) { request.SetDestinationUri(Uri.FromFile(new Java.IO.File(destinationPathName))); } request.SetAllowedOverMetered(allowedOverMetered); Id = downloadManager.Enqueue(request); } }