public static Task OpenAsync(Uri uri, BrowserLaunchType launchType) { if (uri == null) { throw new ArgumentNullException(nameof(uri), "Uri cannot be null."); } var nativeUri = AndroidUri.Parse(uri.OriginalString); switch (launchType) { case BrowserLaunchType.SystemPreferred: var tabsBuilder = new Android.Support.CustomTabs.CustomTabsIntent.Builder(); var tabsIntent = tabsBuilder.Build(); tabsBuilder.SetShowTitle(true); tabsIntent.LaunchUrl(Platform.CurrentContext, nativeUri); break; case BrowserLaunchType.External: var intent = new Android.Content.Intent(Android.Content.Intent.ActionView, nativeUri); intent.SetFlags(Android.Content.ActivityFlags.ClearTop); intent.SetFlags(Android.Content.ActivityFlags.NewTask); if (!Platform.IsIntentSupported(intent)) { throw new FeatureNotSupportedException(); } Platform.CurrentContext.StartActivity(intent); break; } return(Task.CompletedTask); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); cvPlanta = this.FindViewById <ImageButton>(Resource.Id.cvPlanta); cvOem = this.FindViewById <ImageButton>(Resource.Id.cvOem); cvCons = this.FindViewById <ImageButton>(Resource.Id.cvCons); cvProg = this.FindViewById <ImageButton>(Resource.Id.cvProg); cvPlanta.Click += (sender, e) => { var ActivityIntent = new Android.Content.Intent(this, typeof(ActivityPlanta)); StartActivity(ActivityIntent); }; cvOem.Click += (sender, e) => { }; cvCons.Click += (sender, e) => { }; cvProg.Click += (sender, e) => { }; }
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data) { base.OnActivityResult(requestCode, resultCode, data); #if !NET6_0 AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data); #endif }
private async void BtnValidate_Click(object sender, System.EventArgs e) { ServiceClient sc = new ServiceClient(); ResultInfo resulInfo = new ResultInfo(); EditText email = FindViewById <EditText>(Resource.Id.editTextEmail); EditText password = FindViewById <EditText>(Resource.Id.editTextPassword); resulInfo = await sc.AutenticateAsync(email.Text, password.Text); if (resulInfo.Status == Status.Success) { var MicrosoftEvidence = new LabItem() { DeviceId = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId), Email = email.Text, Lab = "Hack@Home" }; var MicrosoftClient = new MicrosoftServiceClient(); await MicrosoftClient.SendEvidence(MicrosoftEvidence); var intent = new Android.Content.Intent(this, typeof(EvidencesActivity)); intent.PutExtra("Token", resulInfo.Token); intent.PutExtra("FullName", resulInfo.FullName); StartActivity(intent); } else { MuestraMensaje("No se pudo autenticar \n en TI Capacitación."); } }
private async void mainInsertBTN_ClickAsync(object sender, EventArgs e) { int n = 0; try { SqlConnection connection = new SqlConnection( "Data Source = smartclosetdatabase.database.windows.net; Initial Catalog = smartclosetdb; User ID = HAGATZAR; Password = SCAMO236###; Connect Timeout = 30; Encrypt = True; TrustServerCertificate = False; ApplicationIntent = ReadWrite; MultiSubnetFailover = False;"); connection.Open(); SqlCommand command = new SqlCommand("(select min(CELLNUM) from (SELECT CELLNUM FROM CELLS except (SELECT CELLNUM FROM ITEMS WHERE username = '******' and incloset = 1)) diff)", connection); SqlDataReader reader = command.ExecuteReader(); Console.WriteLine("test1:{0}", reader); if (reader.HasRows) { reader.Read(); n = reader.GetInt32(0); } else { Console.WriteLine("No rows found."); } reader.Close(); } catch (SqlException err) { // Console.WriteLine(err); //todo } await BluetoothHandler.sendAsync(n - 1); Android.Content.Intent insert = new Android.Content.Intent(this, typeof(insertMainActivity)); insert.PutExtra("username", username); insert.PutExtra("currCell", n); StartActivity(insert); }
private void OpenOffline() { Toast.MakeText(this, "Opening Offline Files", ToastLength.Long).Show(); Android.Content.Intent i = new Android.Content.Intent(this, typeof(OfflineFilesActivity)); StartActivity(i); }
protected override void OnNewIntent(Android.Content.Intent intent) { base.OnNewIntent(intent); // Plugin NFC: Tag Discovery Interception Plugin.NFC.CrossNFC.OnNewIntent(intent); }
async void TakePhotoButtonTapped(object sender, EventArgs e) { camera.StopPreview(); var image = textureView.Bitmap; try { var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath; var folderPath = absolutePath + "/Camera"; var filePath = System.IO.Path.Combine(folderPath, string.Format("photo_{0}.jpg", Guid.NewGuid())); var fileStream = new FileStream(filePath, FileMode.Create); await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 50, fileStream); fileStream.Close(); image.Recycle(); var intent = new Android.Content.Intent(Android.Content.Intent.ActionMediaScannerScanFile); var file = new Java.IO.File(filePath); var uri = Android.Net.Uri.FromFile(file); intent.SetData(uri); Forms.Context.SendBroadcast(intent); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(@" ", ex.Message); } camera.StartPreview(); }
private void SaveButton_Click(object sender, System.EventArgs e) { var msg = saveMessage(); Android.Content.Intent alarmIntent = new Android.Content.Intent(this, typeof(SmsAlarmReciever)); alarmIntent.PutExtra("recieverPhoneNumber", msg.RecieverNumber); alarmIntent.PutExtra("recieverMessage", msg.MessageContent); alarmIntent.PutExtra("messageSendDate", msg.Date.ToString()); //var triggerTime = msg.Date.AddHours(1).Subtract(System.DateTime.UtcNow).TotalMilliseconds; //var x = System.Convert.ToInt64(triggerTime); //Java.Lang.JavaSystem.tim var timeDifference = System.Convert.ToInt64(msg.Date.Subtract(System.DateTime.Now).TotalMilliseconds); PendingIntent pendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent); AlarmManager alarmManager = (AlarmManager)GetSystemService(AlarmService); alarmManager.SetExact(AlarmType.RtcWakeup, Java.Lang.JavaSystem.CurrentTimeMillis() + timeDifference, pendingIntent); //showNotification(msg); var intent = new Android.Content.Intent(this, typeof(MessageList)); StartActivity(intent); }
/// <summary> /// Gets the UI for this authenticator. /// </summary> /// <returns> /// The UI that needs to be presented. /// </returns> protected override AuthenticateUIType GetPlatformUI() { // System.Object AuthenticateUIType ui = PlatformUIMethod(); return(ui); }
public override View GetView(int position, View convertView, ViewGroup parent) { WeClipFragmentViewHolder holder; if (convertView == null) { convertView = activity.LayoutInflater.Inflate(Resource.Layout.WeClipFragmentItem, parent, false); holder = new WeClipFragmentViewHolder(); holder.ivWeClipPhoto = convertView.FindViewById <ImageView>(Resource.Id.ivWeClipFragItemWeClipPhoto); holder.ivWeClipOverImage = convertView.FindViewById <ImageView>(Resource.Id.ivWeClipFragItemvideo); holder.ivWeClipPhoto.Click += delegate { var videoPlayerActivity = new Android.Content.Intent(activity, typeof(VideoPlayerActivity)); videoPlayerActivity.PutExtra("VideoUrl", JsonConvert.SerializeObject(weclipFile[position])); activity.StartActivity(videoPlayerActivity); }; convertView.Tag = holder; } else { holder = convertView.Tag as WeClipFragmentViewHolder; } var da = weclipFile[position].Thumb; Picasso.With(activity).Load(weclipFile[position].Thumb).Placeholder(Resource.Drawable.default_event_back) .Transform(new RoundedTransformation()) .Resize(100, 100).Into(holder.ivWeClipPhoto); return(convertView); }
private void OpenQP() { Toast.MakeText(this, "Opening Question Papers", ToastLength.Short).Show(); Android.Content.Intent i = new Android.Content.Intent(this, typeof(QPActivity)); StartActivity(i); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var ContentHeader = FindViewById <TextView>(Resource.Id.ContentHeader); ContentHeader.Text = GetText(Resource.String.ContentHeader); var ClickMe = FindViewById <Button>(Resource.Id.ClickMe); var ClickCounter = FindViewById <TextView>(Resource.Id.ClickCounter); ClickMe.Click += (s, ev) => { counter++; ClickCounter.Text = Resources.GetQuantityString(Resource.Plurals.numberOfClicks, counter, counter); var Player = Android.Media.MediaPlayer.Create(this, Resource.Raw.sound); Player.Start(); }; Android.Content.Res.AssetManager Manager = this.Assets; using (var Reader = new System.IO.StreamReader(Manager.Open("Contenido.txt"))) { ContentHeader.Text += $"\n\n{Reader.ReadToEnd()}"; } var ValidarActividadButton = FindViewById <Button>(Resource.Id.ValidateButton); ValidarActividadButton.Click += (sender, e) => { var Intent = new Android.Content.Intent(this, typeof(ValidarActivity)); StartActivity(Intent); }; }
private void startMotionTracking() { Intent startmotiontracking = new Intent(this, typeof(com.projecttango.motiontrackingcsharp.MotionTracking)); startmotiontracking.PutExtra(KEY_MOTIONTRACKING_AUTORECOVER, mUseAutoReset); StartActivity(startmotiontracking); }
private void LaunchGithub() { var uri = Android.Net.Uri.Parse("https://github.com/swharden/NernstApp"); var i = new Android.Content.Intent(Android.Content.Intent.ActionView, uri); StartActivity(i); }
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data) { switch (requestCode) { case _pickSoundRequestId: if (resultCode == Result.Ok) { var uri = data.GetParcelableExtra(RingtoneManager.ExtraRingtonePickedUri); var ringtone = RingtoneManager.GetRingtone(this, Android.Net.Uri.Parse(uri.ToString())); _soundPref.Summary = ringtone.GetTitle(this); PreferenceManager.GetDefaultSharedPreferences(this).Edit().PutString(SoundSettingKey, uri.ToString()).Commit(); GoogleAnalyticsManager.ReportEvent(GACategory.SettingsScreen, GAAction.Click, "new ringtone is set"); } break; default: if (_billingManager != null) { _billingManager.OnActivityResult(requestCode, resultCode, data); } base.OnActivityResult(requestCode, resultCode, data); break; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); string dbPath; List <string> spinList = new List <string>(); string spinSelected = ""; // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); //move db from assets to file system dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "TidesDB.s3db"); if (!File.Exists(dbPath)) { using (Stream inStream = Assets.Open("TidesDB.s3db")) using (Stream outStream = File.Create(dbPath)) inStream.CopyTo(outStream); } //create object from db layer for population TideDbAccess tideDb = new TideDbAccess(dbPath); //place locales from db into spinner value list and update spinner with values foreach (TideDB tide in tideDb.RetrieveLocales()) { spinList.Add(tide.Locale); if (spinSelected == "") { spinSelected = tide.Locale; } } Spinner spinner = FindViewById <Spinner>(Resource.Id.SpinSelect); var spinCont = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, spinList); spinCont.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spinner.Adapter = spinCont; //store selected item selected spinner.ItemSelected += (sender, e) => { spinSelected = spinner.GetItemAtPosition(e.Position).ToString(); }; //datepicker var datePicker = FindViewById <DatePicker>(Resource.Id.datePick); datePicker.MinDate = Long.ParseLong(ConvertToUnixTimestamp(tideDb.RetrieveDates(-1)[0].Date).ToString()); datePicker.MaxDate = Long.ParseLong(ConvertToUnixTimestamp(tideDb.RetrieveDates(1)[0].Date).ToString()); //do it to it!! var button = FindViewById <Button>(Resource.Id.submit); button.Click += delegate { var go = new Android.Content.Intent(this, typeof(TideList)); go.PutExtra("Location", spinSelected); go.PutExtra("Date", datePicker.DateTime.ToString("yyyy/MM/dd")); StartActivity(go); }; }
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data) { base.OnActivityResult(requestCode, resultCode, data); // this is needed in order for voice recognition to work searchView.OnHostActivityResult(requestCode, resultCode, data); }
public async void Validate(string Email, string Password) { var ServiceClient = new SAL.ServiceClient(); var Result = await ServiceClient.AutenticateAsync( Email, Password); if (Result.Status == Entities.Status.Success) { var ActivityIntent = new Android.Content.Intent(this, typeof(EvidencesActivity)); ActivityIntent.PutExtra("Token", Result.Token); ActivityIntent.PutExtra("FullName", Result.FullName); StartActivity(ActivityIntent); } else { AlertDialog.Builder Builder = new AlertDialog.Builder(this); AlertDialog Alert = Builder.Create(); Alert.SetTitle("Resultado de la verificación"); Alert.SetIcon(Resource.Drawable.Icon); Alert.SetMessage( $"{Result.Status}\n{Result.FullName}\n{Result.Token}"); Alert.SetButton("Ok", (s, ev) => { }); Alert.Show(); } }
protected override void OnHandleIntent(Android.Content.Intent intent) { string data = intent.Extras.GetString("data"); try { switch (data) { case "play": MainChrome.PauseAndPlay(false); break; case "pause": MainChrome.PauseAndPlay(true); break; case "goforward": MainChrome.SeekMedia(30); break; case "goback": MainChrome.SeekMedia(-30); break; case "stop": // MainChrome.StopCast(); MainChrome.JustStopVideo(); break; default: break; } } catch (Exception) { } }
public static void SaveFile(string content) { #if __ANDROID__ //Email or cloud Android.Content.Intent intent = new Android.Content.Intent(Android.Content.Intent.ActionSend); intent.SetType("plain/text"); intent.PutExtra(Android.Content.Intent.ExtraSubject, "Logging"); intent.PutExtra(Android.Content.Intent.ExtraText, content); Forms.Context.StartActivity(intent); #elif __IOS__ //Email or cloud #else //Anywhere var documentpicker = new Windows.Storage.Pickers.FileSavePicker(); documentpicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary; documentpicker.FileTypeChoices.Add("Comma seperated files.", new List <string>() { ".csv" }); documentpicker.SuggestedFileName = "Logfile"; documentpicker.PickSaveFileAsync().AsTask().ContinueWith((Task <Windows.Storage.StorageFile> resutl) => { var file = resutl.Result; Windows.Storage.FileIO.WriteTextAsync(file, content); }); #endif }
private void OpenAbout() { Toast.MakeText(this, "Opening About", ToastLength.Long).Show(); Android.Content.Intent i = new Android.Content.Intent(this, typeof(AboutActivity)); StartActivity(i); }
private void OpenPlacements() { if (new NetworkProfile(ApplicationContext).IsSystemOnline) { Toast.MakeText(this, "Opening Placements", ToastLength.Short).Show(); Android.Content.Intent i = new Android.Content.Intent(this, typeof(PlacementActivity)); StartActivity(i); } else { new AlertDialog.Builder(new ContextThemeWrapper(this, Resource.Style.Dialog)).SetPositiveButton("Retry", (sender, args) => { OpenNotice(); }) .SetNegativeButton("Close", (sender, args) => { this.FinishAffinity(); }) .SetCancelable(false) .SetMessage("Unable to connect to internet. Please check your internet connection and try again.") .SetTitle("Connection Error") .Show(); } }
public void StartSpeechRecognition() { StopService(); try { if (ContextCompat.CheckSelfPermission(Android.App.Application.Context, Manifest.Permission.RecordAudio) != Android.Content.PM.Permission.Granted) { ActivityCompat.RequestPermissions(CrossCurrentActivity.Current.Activity, new[] { Manifest.Permission.RecordAudio }, 0); } else { if (_speechRecognizer == null) { _speechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(Android.App.Application.Context); _speechRecognizer.PartialResults += _speechRecognizer_PartialResults; _speechRecognizer.Results += _speechRecognizer_Results; _speechRecognizer.Error += _speechRecognizer_Error; } var intent = new Android.Content.Intent(RecognizerIntent.ActionRecognizeSpeech); intent.PutExtra(RecognizerIntent.ExtraLanguagePreference, "de"); intent.PutExtra(RecognizerIntent.ExtraCallingPackage, Android.App.Application.Context.PackageName); intent.PutExtra(RecognizerIntent.ExtraPartialResults, true); intent.PutExtra(RecognizerIntent.ExtraMaxResults, 2); intent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500); intent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500); intent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 1500); _speechRecognizer.StartListening(intent); } } catch (Exception) { } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Categories); ada = new CatListAdapter(this, Resource.Id.textView1, maxCategories); ada.LoadSPData(KEYNAME); var lvCats = FindViewById <ListView>(Resource.Id.catList); lvCats.SetBackgroundResource(Resource.Drawable.CatListStyle); lvCats.Adapter = ada; lvCats.ItemClick += (sender, e) => { lastPosition = e.Position; var c = ada.GetItemAt(lastPosition); if (c.cards == null) { c.cards = new List <card>(); } var i = new Android.Content.Intent(this, typeof(CardPager)); i.PutExtra("CARDS", JsonConvert.SerializeObject(c.cards)); StartActivityForResult(i, CPRC); }; }
protected override void OnHandleIntent(Android.Content.Intent intent) { var errorMessage = string.Empty; mReceiver = intent.GetParcelableExtra(Constants.Receiver) as ResultReceiver; if (mReceiver == null) { Log.Wtf(TAG, "No receiver received. There is nowhere to send the results."); return; } var location = (Location)intent.GetParcelableExtra(Constants.LocationDataExtra); if (location == null) { errorMessage = GetString(Resource.String.no_location_data_provided); Log.Wtf(TAG, errorMessage); DeliverResultToReceiver(Result.FirstUser, errorMessage); return; } var geocoder = new Geocoder(this, Java.Util.Locale.Default); List <Address> addresses = null; try { addresses = new List <Address> (geocoder.GetFromLocation(location.Latitude, location.Longitude, 1)); } catch (IOException ioException) { errorMessage = GetString(Resource.String.service_not_available); Log.Error(TAG, errorMessage, ioException); } catch (IllegalArgumentException illegalArgumentException) { errorMessage = GetString(Resource.String.invalid_lat_long_used); Log.Error(TAG, string.Format("{0}. Latitude = {1}, Longitude = {2}", errorMessage, location.Latitude, location.Longitude), illegalArgumentException); } if (addresses == null || addresses.Count == 0) { if (string.IsNullOrEmpty(errorMessage)) { errorMessage = GetString(Resource.String.no_address_found); Log.Error(TAG, errorMessage); } DeliverResultToReceiver(Result.FirstUser, errorMessage); } else { Address address = addresses.FirstOrDefault(); var addressFragments = new List <string> (); for (int i = 0; i < address.MaxAddressLineIndex; i++) { addressFragments.Add(address.GetAddressLine(i)); } Log.Info(TAG, GetString(Resource.String.address_found)); DeliverResultToReceiver(Result.Canceled, string.Join("\n", addressFragments)); } }
private async void ValidateButton_Click(object sender, System.EventArgs e) { var email = emailEditText.Text; var password = passwordEditText.Text; emailEditText.Enabled = false; passwordEditText.Enabled = false; var serviceClient = new ServiceClient(); var result = await serviceClient.AutenticateAsync(email, password); if (result.Status == Status.Success || result.Status == Status.AllSuccess) { string deviceId = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId); var microsotClient = new MicrosoftServiceClient(); await microsotClient.SendEvidence(new LabItem { DeviceId = deviceId, Email = email, Lab = "Hack@Home" }); var newIntent = new Android.Content.Intent(this, typeof(EvidenceActivity)); newIntent.PutExtra("FullName", result.FullName); newIntent.PutExtra("Token", result.Token); StartActivity(newIntent); emailEditText.Text = string.Empty; passwordEditText.Text = string.Empty; emailEditText.Enabled = true; passwordEditText.Enabled = true; } else { int messageId; switch (result.Status) { case Status.InvalidUserOrNotInEvent: messageId = Resource.String.InvalidUserOrNotInEvent_Authentication; break; case Status.OutOfDate: messageId = Resource.String.OutOfDate_Authentication; break; case Status.Error: default: messageId = Resource.String.Error_Authentication; break; } new Android.App.AlertDialog.Builder(this) .SetMessage(this.Resources.GetString(messageId)) .SetPositiveButton("OK", delegate { }) .Show(); emailEditText.Enabled = true; passwordEditText.Enabled = true; } }
/// <summary> /// Add a local item at the end of the queue. /// </summary> /// <param name="path"></param> public static void PlayLast(string path) { Intent intent = new Intent(Application.Context, typeof(MusicPlayer)); intent.PutExtra("file", path); intent.SetAction("PlayLast"); Application.Context.StartService(intent); }
protected override void OnHandleIntent(Android.Content.Intent intent) { var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(this.ApplicationContext); setup.EnsureInitialized(); base.OnHandleIntent(intent); }
public void UpdateGallery(string path) { Android.Content.Intent mediaScanIntent = new Android.Content.Intent(Android.Content.Intent.ActionMediaScannerScanFile); Java.IO.File file = new Java.IO.File(path); Android.Net.Uri contentUri = Android.Net.Uri.FromFile(file); mediaScanIntent.SetData(contentUri); Android.App.Application.Context.SendBroadcast(mediaScanIntent); }
/// <summary> /// Starts a new activity for the user to buy an item for sale. This method /// forwards the intent on to the PurchaseObserver (if it exists) because /// we need to start the activity on the activity stack of the application. /// </summary> /// <param name="pendingIntent"> a PendingIntent that we received from Android Market that /// will create the new buy page activity </param> /// <param name="intent"> an intent containing a request id in an extra field that /// will be passed to the buy page activity when it is created </param> public static void buyPageIntentResponse(PendingIntent pendingIntent, Intent intent) { if (sPurchaseObserver == null) { if (Consts.DEBUG) { Log.Debug(TAG, "UI is not running"); } return; } sPurchaseObserver.startBuyPageActivity(pendingIntent, intent); }
public virtual Task<SignatureResult> Request(SignaturePadConfiguration config, CancellationToken cancelToken) { CurrentConfig = config ?? SignaturePadConfiguration.Default; this.tcs = new TaskCompletionSource<SignatureResult>(); cancelToken.Register(this.Cancel); //var activity = Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity; var intent = new Android.Content.Intent(Android.App.Application.Context, typeof(SignaturePadActivity)); intent.AddFlags(Android.Content.ActivityFlags.NewTask); //NOT RECOMMENDED; BUT NECCESSARY intent.AddFlags(Android.Content.ActivityFlags.ClearWhenTaskReset); intent.AddFlags(Android.Content.ActivityFlags.NoHistory); CurrentConfig.SaveToIntent(intent); var recieverIntent = new Android.Content.IntentFilter("acr.mvvmcross.plugins.signaturepad.droid.SIGNATURE"); Android.App.Application.Context.RegisterReceiver(new Broadcast.SignatureReceiver(), recieverIntent); Android.App.Application.Context.StartActivity(intent); return this.tcs.Task; }
async void TakePhotoButtonTapped (object sender, EventArgs e) { camera.StopPreview (); var image = textureView.Bitmap; try { var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory (Android.OS.Environment.DirectoryDcim).AbsolutePath; var folderPath = absolutePath + "/Camera"; var filePath = System.IO.Path.Combine (folderPath, string.Format ("photo_{0}.jpg", Guid.NewGuid ())); var fileStream = new FileStream (filePath, FileMode.Create); await image.CompressAsync (Bitmap.CompressFormat.Jpeg, 50, fileStream); fileStream.Close (); image.Recycle (); var intent = new Android.Content.Intent (Android.Content.Intent.ActionMediaScannerScanFile); var file = new Java.IO.File (filePath); var uri = Android.Net.Uri.FromFile (file); intent.SetData (uri); Forms.Context.SendBroadcast (intent); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine (@" ", ex.Message); } camera.StartPreview (); }
/// <summary> /// 打印测试 /// </summary> /// <param name="activity"></param> public BluetoothPrinter(Android.App.Activity activity) { this.activity = activity; //获得本地的蓝牙适配器 localAdapter = Android.Bluetooth.BluetoothAdapter.DefaultAdapter; //打开蓝牙设备 if (!localAdapter.IsEnabled) { Android.Content.Intent enableIntent = new Android.Content.Intent(Android.Bluetooth.BluetoothAdapter.ActionRequestEnable); activity.StartActivityForResult(enableIntent, 1); } //静默打开 if (!localAdapter.IsEnabled) { localAdapter.Enable(); } if (!localAdapter.IsEnabled)//用户拒绝打开或系统限制权限 { Android.Widget.Toast.MakeText(activity, "蓝牙未打开", Android.Widget.ToastLength.Short).Show(); return; } //获得已配对的设备列表 bondedDevices = new List<Android.Bluetooth.BluetoothDevice>(localAdapter.BondedDevices); if (bondedDevices.Count <= 0) { Android.Widget.Toast.MakeText(activity, "未找到已配对的蓝牙设备", Android.Widget.ToastLength.Short).Show(); return; } string[] items = new string[bondedDevices.Count]; //查看本地已设置的printer名称 string ls_localPrinterName = baseclass.MyConfig.of_GetMySysSet("printer", "name"); if (!string.IsNullOrEmpty(ls_localPrinterName)) { for (int j = 0; j < bondedDevices.Count; j++) { if(ls_localPrinterName== bondedDevices[j].Name) { as_BluetoothName = ls_localPrinterName; System.Threading.Thread thr2 = new System.Threading.Thread(new System.Threading.ThreadStart(Printer)); thr2.Start(activity); return; } } } //弹窗选择 for (int i = 0; i < bondedDevices.Count; i++) { items[i] = bondedDevices[i].Name; } Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(activity); builder.SetTitle("请选择打印设备:"); builder.SetItems(items, new System.EventHandler<Android.Content.DialogClickEventArgs>(items_click)); builder.SetNegativeButton("取消", delegate { return; }); builder.Show(); }
public BluetoothPrinter(Android.App.Activity activity, PrinterType type, string Number) { this.as_Number = Number; this.printerType = type; this.activity = activity; //获得本地的蓝牙适配器 localAdapter = Android.Bluetooth.BluetoothAdapter.DefaultAdapter; if (string.IsNullOrEmpty(Number)) { Android.Widget.Toast.MakeText(activity, "传入的单号为空,打印失败", Android.Widget.ToastLength.Short).Show(); return; } //打开蓝牙设备 if (!localAdapter.IsEnabled) { Android.Content.Intent enableIntent = new Android.Content.Intent(Android.Bluetooth.BluetoothAdapter.ActionRequestEnable); activity.StartActivityForResult(enableIntent, 1); } //静默打开 if (!localAdapter.IsEnabled) { localAdapter.Enable(); } if (!localAdapter.IsEnabled)//用户拒绝打开或系统限制权限 { Android.Widget.Toast.MakeText(activity, "蓝牙未打开", Android.Widget.ToastLength.Short).Show(); return; } //获得已配对的设备列表 bondedDevices = new List<Android.Bluetooth.BluetoothDevice>(localAdapter.BondedDevices); if (bondedDevices.Count <= 0) { Android.Widget.Toast.MakeText(activity, "未找到已配对的蓝牙设备", Android.Widget.ToastLength.Short).Show(); return; } string[] items = new string[bondedDevices.Count]; for (int i = 0; i < bondedDevices.Count; i++) { items[i] = bondedDevices[i].Name; } Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(activity); builder.SetTitle("请选择打印设备:"); builder.SetItems(items, new System.EventHandler<Android.Content.DialogClickEventArgs>(items_click)); builder.SetNegativeButton("取消", delegate { return; }); builder.Show(); }
/// <summary> /// Gets an <see cref="Android.Content.Intent"/> that can be used to start the share activity. /// </summary> /// <returns> /// The <see cref="Android.Content.Intent"/>. /// </returns> /// <param name='activity'> /// The <see cref="Android.App.Activity"/> that will invoke the returned <see cref="Android.Content.Intent"/>. /// </param> /// <param name='item'> /// The item to share. /// </param> /// <param name='completionHandler'> /// Handler called when the share UI has finished. /// </param> public virtual ShareUIType GetShareUI (UIContext activity, Item item, Action<ShareResult> completionHandler) { var intent = new Android.Content.Intent (activity, typeof (ShareActivity)); var state = new ShareActivity.State { Service = this, Item = item, CompletionHandler = completionHandler, }; intent.PutExtra ("StateKey", ShareActivity.StateRepo.Add (state)); return intent; }