Example #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate {
                button.Text = string.Format("{0} clicks!", count++); };

            var file = fileFromAsset(this, "test.pdf");

            //var uri = Android.Net.Uri.FromFile(new File("file:///android_asset/test.pdf"));

            var uri = Android.Net.Uri.Parse(file.AbsolutePath);
            var intent = new Intent (this, typeof (MuPDFActivity));
            intent.SetFlags (ActivityFlags.NoHistory);
            intent.SetAction (Intent.ActionView);
            intent.SetData(uri);
            this.StartActivity(intent);
        }
Example #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
            Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
            Button callButton = FindViewById<Button>(Resource.Id.CallButton);
            Button callHistoryButton = FindViewById<Button>(Resource.Id.CallHistoryButton);

            // "Call" を Disable にします
            callButton.Enabled = false;
            // 番号を変換するコードを追加します。
            string translatedNumber = string.Empty;
            translateButton.Click += (object sender, EventArgs e) =>
            {
                // ユーザーのアルファベットの電話番号を電話番号に変換します。
                translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);
                if (String.IsNullOrWhiteSpace(translatedNumber))
                {
                    callButton.Text = "Call";
                    callButton.Enabled = false;
                }
                else
                {
                    callButton.Text = "Call " + translatedNumber;
                    callButton.Enabled = true;
                }
            };

            callButton.Click += (object sender, EventArgs e) =>
            {
                // "Call" ボタンがクリックされたら電話番号へのダイヤルを試みます。
                var callDialog = new AlertDialog.Builder(this);
                callDialog.SetMessage("Call " + translatedNumber + "?");
                callDialog.SetNeutralButton("Call", delegate
                {
                    // 掛けた番号のリストに番号を追加します。
                    phoneNumbers.Add(translatedNumber);
                    // Call History ボタンを有効にします。
                    callHistoryButton.Enabled = true;
                    // 電話への intent を作成します。
                    var callIntent = new Intent(Intent.ActionCall);
                    callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
                    StartActivity(callIntent);
                });
                callDialog.SetNegativeButton("Cancel", delegate { });
                // アラートダイアログを表示し、ユーザーのレスポンスを待ちます。
                callDialog.Show();
            };

            callHistoryButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(CallHistoryActivity));
                intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
                StartActivity(intent);
            };
        }
Example #3
0
        public void AddEvent(string name, DateTime startTime, DateTime endTime)
        {
            Intent intent = new Intent(Intent.ActionInsert);
            intent.SetData(Android.Provider.CalendarContract.Events.ContentUri);

            // Add Event Details
            intent.PutExtra(Android.Provider.CalendarContract.ExtraEventBeginTime, DateTimeJavaDate(startTime));
            intent.PutExtra(Android.Provider.CalendarContract.ExtraEventEndTime, DateTimeJavaDate(endTime));
            intent.PutExtra(Android.Provider.CalendarContract.EventsColumns.AllDay, false);
            //			intent.PutExtra(Android.Provider.CalendarContract.EventsColumns.EventLocation, ""); TODO: event location
            intent.PutExtra(Android.Provider.CalendarContract.EventsColumns.Description, "UTS:HELPS Workshop");
            intent.PutExtra(Android.Provider.CalendarContract.EventsColumns.Title, name);

            // open "Add to calendar" screen
            Forms.Context.StartActivity(intent);

            //			TODO: add event directly
            //			https://github.com/xamarin/monodroid-samples/blob/master/CalendarDemo/EventListActivity.cs
            //
            //			ContentValues eventValues = new ContentValues ();
            //			eventValues.Put (CalendarContract.Events.InterfaceConsts.CalendarId, ?? ?);
            //			eventValues.Put (CalendarContract.Events.InterfaceConsts.Title, "Test Event");
            //			eventValues.Put (CalendarContract.Events.InterfaceConsts.Description, "This is an event created from Mono for Android");
            //			eventValues.Put (CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS (2011, 12, 15, 10, 0));
            //			eventValues.Put (CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS (2011, 12, 15, 11, 0));
            //
            //			eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC");
            //			eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC");
            //
            //			var uri = ContentResolver.Insert (CalendarContract.Events.ContentUri, eventValues);
            //			Console.WriteLine ("Uri for new event: {0}", uri);
        }
 void introVidBtn_Click(object sender, EventArgs e)
 {
     string videoUrl = "https://openlabdata.blob.core.windows.net/videotuts/pacingIntro.mp4";
     Intent i = new Intent(Intent.ActionView);
     i.SetData(Android.Net.Uri.Parse(videoUrl));
     StartActivity(i);
 }
        ImageView _imageView; // create variable to grab the imagview

        #endregion Fields

        #region Methods

        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data); // base is the same thing as super

            // Make it available in the gallery

            Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);//scan a file and add it to media database
            Android.Net.Uri contentUri = Android.Net.Uri.FromFile(App._file); //gets the image file
            mediaScanIntent.SetData(contentUri); // put image file into media database
            SendBroadcast(mediaScanIntent);  //

            // Display in ImageView. We will resize the bitmap to fit the display.
            // Loading the full sized image will consume to much memory
            // and cause the application to crash.

            int height = Resources.DisplayMetrics.HeightPixels;
            int width = _imageView.Height;
            App.bitmap = App._file.Path.LoadAndResizeBitmap(width, height);
            if (App.bitmap != null)
            {
                _imageView.SetImageBitmap(App.bitmap); //set the bitmap to the image view
                App.bitmap = null;
            }

            // Dispose of the Java side bitmap.
            GC.Collect();
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource.
            SetContentView (Resource.Layout.Main);

            // Get our UI controls from the loaded layout:
            EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
            Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
            Button callButton = FindViewById<Button>(Resource.Id.CallButton);
            Button callHistoryButton = FindViewById<Button> (Resource.Id.CallHistoryButton);

            // Disable the "Call" button.
            callButton.Enabled = false;

            // Add code to translate number.
            string translatedNumber = string.Empty;

            translateButton.Click += (object sender, EventArgs e) => {
                // Translate user's alphanumeric phone number to numeric.
                translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);

                if (String.IsNullOrWhiteSpace(translatedNumber)) {
                    callButton.Text = "Call";
                    callButton.Enabled = false;
                } else {
                    callButton.Text = "Call " + translatedNumber;
                    callButton.Enabled = true;
                }
            };

            callButton.Click += (object sender, EventArgs e) => {
                // On "Call" button click, try to dial phone number.
                var callDialog = new AlertDialog.Builder(this);
                callDialog.SetMessage("Call " + translatedNumber + "?");
                callDialog.SetNeutralButton("Call", delegate {
                    // Add dialed number to list of called numbers.
                    phoneNumbers.Add(translatedNumber);

                    // Enable the Call History button.
                    callHistoryButton.Enabled = true;

                    // Create intent to dial phone.
                    var callIntent = new Intent(Intent.ActionCall);
                    callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
                    StartActivity(callIntent);
                });
                callDialog.SetNegativeButton("Cancel", delegate {});

                // Show the alert dialog to the user and wait for response.
                callDialog.Show();
            };

            callHistoryButton.Click += (sender, e) => {
                var intent = new Intent(this, typeof(CallHistoryActivity));
                intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
                StartActivity(intent);
            };
        }
Example #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            FindViewById <BootstrapButton>(Resource.Id.github_btn).SetOnClickListener(new ViewOnClick(v =>
            {
                var intent = new Android.Content.Intent(Intent.ActionView);
                //StartActivity(intent);
                intent.SetData(Android.Net.Uri.Parse("https://github.com/code-jar/Android-Bootstrap"));
                StartActivity(intent);
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_button).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapButtonExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_fontawesometext).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(AwesomeTextViewExample))); }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_label).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapLabelExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_progress).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapProgressBarExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_progress_group).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapProgressBarGroupExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_btn_group).SetOnClickListener(new ViewOnClick(v => { StartActivity(new Intent(this, typeof(BootstrapButtonGroupExample))); }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_cricle_thumbnail).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapCircleThumbnailExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_edit_text).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapEditTextExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_thumbnail).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapThumbnailExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_well).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapWellExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_dropdown).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapDropDownExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_alert).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapAlertExample)));
            }));
            FindViewById <BootstrapButton>(Resource.Id.example_bootstrap_badge).SetOnClickListener(new ViewOnClick(v =>
            {
                StartActivity(new Intent(this, typeof(BootstrapBadgeExample)));
            }));
        }
        // Launch the device browser so the user can complete the checkout.
        private void OnWebCheckoutButtonClicked(object sender, EventArgs e)
        {
            var intent = new Intent(Intent.ActionView);
            intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
            intent.SetData(Android.Net.Uri.Parse(SampleApplication.Checkout.WebUrl));

            try
            {
                intent.SetPackage("com.android.chrome");
                StartActivity(intent);
            }
            catch (Exception)
            {
                try
                {
                    // Chrome could not be opened, attempt to us other launcher
                    intent.SetPackage(null);
                    StartActivity(intent);
                }
                catch (Exception)
                {
                    OnError(GetString(Resource.String.checkout_error));
                }
            }
        }
 public void Show()
 {
     Intent intent = new Intent(Intent.ActionView);
     intent.SetData(Android.Net.Uri.Parse(Uri.OriginalString));
     intent.SetFlags(ActivityFlags.NewTask);
     Application.Context.StartActivity(intent);
 }
        public void OnSourceCodeClick(object sender, System.EventArgs e)
        {
            Intent i = new Intent(Intent.ActionView);
            i.SetData(Uri.Parse(GetString(Resource.String.sources_link)));

            StartActivity(i);
        }
Example #11
0
        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);
                MainActivity.Instance.SendBroadcast(intent);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(@"				", ex.Message);
            }

            camera.StartPreview();
        }
 public void Show()
 {
     Intent intent = new Intent(Intent.ActionView);
     intent.SetData(Uri.Parse("market://details?id=" + Application.Context.PackageName));
     intent.SetFlags(ActivityFlags.NewTask);
     Application.Context.StartActivity(intent);
 }
Example #13
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            // Make it available in the gallery

            Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
            Uri contentUri = Uri.FromFile(App._file);
            mediaScanIntent.SetData(contentUri);
            SendBroadcast(mediaScanIntent);

            // Display in ImageView. We will resize the bitmap to fit the display
            // Loading the full sized image will consume to much memory
            // and cause the application to crash.

            int height = Resources.DisplayMetrics.HeightPixels;
            int width = iv1.Height ;
            App.bitmap = App._file.Path.LoadAndResizeBitmap (width, height);

            if (App.bitmap != null) {
                iv1.SetImageBitmap (App.bitmap);
                App.bitmap = null;
            }

            if ((requestCode == PickImageId) && (resultCode == Result.Ok))
            {
                Uri uri = data.Data;
                iv1.SetImageURI(uri);
            }

            // Dispose of the Java side bitmap.
            GC.Collect();
        }
Example #14
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
                case Resource.Id.actionEdit:
                    Intent editIntent = new Intent(this, typeof(EditActivity));
                    editIntent.PutExtra("parkid", _park.Id);
                    StartActivityForResult(editIntent, 1);
                    return true;
                case Resource.Id.actionPhotos:

                    Intent urlIntent = new Intent(Intent.ActionView);
                    urlIntent.SetData(Android.Net.Uri.Parse(
                            String.Format("http://www.bing.com/images/search?q={0}", _park.Name)));
                    StartActivity(urlIntent);
                    return true;

                case Resource.Id.actionDirections:

                    if (_park.Latitude.HasValue && _park.Longitude.HasValue)
                    {
                        Intent mapIntent = new Intent(Intent.ActionView,
                            Android.Net.Uri.Parse(
                            string.Format("geo:0,0?q={0},{1}&z=16 ({2})",
                                    _park.Latitude, _park.Longitude, _park.Name)));
                        StartActivity(mapIntent);
                    }
                    return true; // Navigate to the Detail View

                default:
                    return base.OnOptionsItemSelected(item);
            }
        }
Example #15
0
 private void Dial()
 {
     var book = new Xamarin.Contacts.AddressBook(this);
     book.RequestPermission().ContinueWith(t =>
         {
             if (!t.Result)
             {
                 Console.WriteLine("Permission denied by user or manifest");
                 return;
             }
             var validContacts = book.Where(a => a.Phones.Any(b => b.Number.Any())).ToList();
             var totalValidContacts = validContacts.Count;
             if (totalValidContacts < 1)
             {
                 var alert = new AlertDialog.Builder(this);
                 alert.SetTitle("No valid Contacts Found");
                 alert.SetMessage("No valid Contacts Found");
             }
             var rnd = new Random();
             Contact contact = null;
             while (contact == null)
             {
                 contact = validContacts.Skip(rnd.Next(0, totalValidContacts)).FirstOrDefault();
             }
             var urlNumber = Android.Net.Uri.Parse("tel:" + contact.Phones.First().Number);
             var intent = new Intent(Intent.ActionCall);
             intent.SetData(urlNumber);
             this.StartActivity(intent);
         }, TaskScheduler.FromCurrentSynchronizationContext());
 }
Example #16
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
                case Resource.Id.actionEdit:
                    Intent editIntent = new Intent(this, typeof(EditActivity));
                    editIntent.PutExtra("locationid", _location.Id);
                    StartActivityForResult(editIntent, 1);
                    return true;

                case Resource.Id.actionPhotos:

                    Intent urlIntent = new Intent(Intent.ActionView);
                    urlIntent.SetData(Android.Net.Uri.Parse(String.Format("http://www.bing.com/images/search?q={0}", _location.Name))); //$"http://www.bing.com/images/search?q={_location.Name}"));
                    StartActivity(urlIntent);
                    return true;

                case Resource.Id.actionDirections:

                    if ((_location.Latitude.HasValue) && (_location.Longitude.HasValue))
                    {
                        Intent mapIntent = new Intent(Intent.ActionView,
                        Android.Net.Uri.Parse(String.Format("geo:{0},{1}", _location.Latitude, _location.Longitude)));//$"geo:{_location.Latitude},{_location.Longitude}"));
                        StartActivity(mapIntent);
                    }
                    return true;

                default:
                    return base.OnOptionsItemSelected(item);
            }

        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.RatingDialog);

			_cancelButton = FindViewById<Button> (Resource.Id.never_ask);
			_rateButton = FindViewById<Button> (Resource.Id.rate_now);
			_remindLaterButton = FindViewById<Button> (Resource.Id.rate_later);

			var prefs = PreferenceManager.GetDefaultSharedPreferences (this);

			_cancelButton.Click += (sender, e) => {
				prefs.Edit ().PutBoolean (SettingsScreen.ShouldAskForRating, false).Commit ();
				Finish ();
			};
			_rateButton.Click += (sender, e) => {
				prefs.Edit ().PutBoolean (SettingsScreen.ShouldAskForRating, false).Commit ();

				var intent = new Intent (Intent.ActionView);
				intent.SetData (Android.Net.Uri.Parse ("market://details?id=" + PackageName));
				StartActivity (intent);

				Finish ();
			};
			_remindLaterButton.Click += (sender, e) => {
				prefs.Edit ().PutInt (SettingsScreen.StartsCount, 0).Commit ();
				Finish ();
			};
		}
 /// <summary>
 /// REQUIRES android.permission.CALL_PHONE
 /// </summary>
 void Call(int number)
 {
     String uri = "tel:" + number.ToString();
     Intent intent = new Intent(Intent.ActionCall);
     intent.SetData(Android.Net.Uri.Parse(uri));
     StartActivity(intent); 
 }
        void FeedbackTextViewClick(object sender, System.EventArgs e)
        {
            var intent = new Intent(Intent.ActionSendto);
            intent.SetData(Android.Net.Uri.FromParts("mailto", Constants.DeveloperEmail, null));
            StartActivity(intent);

            GoogleAnalyticsManager.ReportEvent(GACategory.AboutScreen, GAAction.Click, "send email");
        }
Example #20
0
 public static void Email(Context context, string to, string subject, string message)
 {
     Intent i = new Intent(Intent.ActionView);
     string uri = "mailto:" + to +  "?subject=" + subject + "&body=" + message;
     i.SetData(Uri.Parse(uri));
     i.PutExtra(Intent.ExtraEmail, new[] { to });
     context.StartActivity(i);
 }
Example #21
0
 public static void AddFileToGallery(Context context, string filePath)
 {
     Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
     File file = new File(filePath);
     var contentUri = Uri.FromFile(file);
     mediaScanIntent.SetData(contentUri);
     context.SendBroadcast(mediaScanIntent);
 }
        void RateTextViewClick(object sender, System.EventArgs e)
        {
            var intent = new Intent(Intent.ActionView);
            intent.SetData(Uri.Parse("market://details?id=" + PackageName));
            StartActivity(intent);

            GoogleAnalyticsManager.ReportEvent(GACategory.AboutScreen, GAAction.Click, "rate on store");
        }
Example #23
0
		public void ComposeEmail (string to, string cc, string subject, string body, bool isHtml)
		{
            var email = new Intent(Intent.ActionSendto);
            email.SetData(Android.Net.Uri.FromParts("mailto", to, null));

            //var intent = Intent.CreateChooser(email, StringResources.EmailDeveloper);
			Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity.StartActivity(email);
		}
Example #24
0
        public static PendingIntent GetNotificationPendingIntent(int id)
        {
            var intent = new Intent(Application.Context.ApplicationContext, typeof(AlarmBroadcastReceiver));
            intent.SetData(Android.Net.Uri.Parse("notification://" + id));

            var pending = PendingIntent.GetBroadcast(Application.Context, 0, intent, PendingIntentFlags.CancelCurrent);
            return pending;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            EditText txtPhoneNumber = FindViewById<EditText>(Resource.Id.txtPhoneNumber);
            Button btnTranslate = FindViewById<Button>(Resource.Id.btnTranslate);
            Button btnCall = FindViewById<Button>(Resource.Id.btnCall);
            Button btnGetLocation = FindViewById<Button>(Resource.Id.btnLocation);

            btnCall.Enabled = false;

            string translatedNumber = string.Empty;
            btnTranslate.Click += (object o, EventArgs e)=> {
                translatedNumber = PhoneTranslator.ToNumber(txtPhoneNumber.Text);
                if (string.IsNullOrWhiteSpace(translatedNumber))
                {
                    btnCall.Text = "Call";
                    btnCall.Enabled = false;
                }
                else
                {
                    btnCall.Text = string.Format("Call {0}", translatedNumber);
                    btnCall.Enabled = true;
                }
            };

            btnCall.Click += (object o, EventArgs e) => {
                //初始化对话框
                var callDialog = new AlertDialog.Builder(this);

                //对话框内容
                callDialog.SetMessage(string.Format("Call {0}?", translatedNumber));

                callDialog.SetNeutralButton("Call", delegate {
                    var callIntent = new Intent(Intent.ActionCall);

                    callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));

                    StartActivity(callIntent);
                });
                callDialog.SetNegativeButton("Cancel", delegate { });

                callDialog.Show();
            };

            btnGetLocation.Click += (o, e) => {  
                // Get Location
                LocationManager lm = (LocationManager)GetSystemService(LocationService);
                var tent = new Intent(this, typeof(LocationBroadCast));
                var ptent = PendingIntent.GetBroadcast(this, 0, tent, PendingIntentFlags.UpdateCurrent);
                lm.RequestLocationUpdates(GetBestLocationProvider(lm), 5000, 100, ptent);
            };
        }
Example #26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
            Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
            Button callButton = FindViewById<Button>(Resource.Id.CallButton);
            Button callHistoryButton = FindViewById<Button>(Resource.Id.CallHistoryButton);

            callButton.Enabled = false;

            string translatedNumber = string.Empty;

            translateButton.Click += (object sender, EventArgs e) =>
                {
                    translatedNumber = Phoneword.PhoneTranslator.ToNumber(phoneNumberText.Text);
                    if (string.IsNullOrWhiteSpace(translatedNumber))
                    {
                        callButton.Text = "Call";
                        callButton.Enabled = false;
                    }
                    else
                    {
                        callButton.Text = "Call " + translatedNumber;
                        callButton.Enabled = true;
                    }
                };

            callButton.Click += (object sender, EventArgs e) =>
                {
                    var callDialog = new AlertDialog.Builder(this);
                    callDialog.SetMessage("Call " + translatedNumber + "?");
                    callDialog.SetNeutralButton("Call", delegate
                    {
                        //Ajoute le numéro à la liste des numéros appelés
                        phoneNumbers.Add(translatedNumber);
                        //Active le bouton
                        callHistoryButton.Enabled = true;
                        //Crée un Intent pour lancer un appel
                        var callIntent = new Intent(Intent.ActionCall);
                        callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
                        StartActivity(callIntent);
                    });
                    callDialog.SetNegativeButton("Cancel", delegate { });
                    callDialog.Show();
                };

            callHistoryButton.Click += (object sender, EventArgs e) =>
                {
                    var intent = new Intent(this, typeof(CallHistoryActivity));
                    intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
                    StartActivity(intent);
                };
        }
Example #27
0
		public void SendEmail(string destination, string subject)
		{
			Intent emailIntent = new Intent(Intent.ActionSendto);

			emailIntent.SetData(Android.Net.Uri.Parse("mailto:" + destination));

			emailIntent.PutExtra (Intent.ExtraSubject, subject);

			AppCompatActivityBase.CurrentActivity.StartActivity(Intent.CreateChooser(emailIntent, "Send mail..."));
		}
Example #28
0
		protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
		{
			base.OnActivityResult (requestCode, resultCode, data);

			// Add the image to the photo gallery
			var mediaScanIntent = new Intent (Intent.ActionMediaScannerScanFile);
			Android.Net.Uri contentUri = Android.Net.Uri.FromFile (ImageInfo._file);
			mediaScanIntent.SetData (contentUri);
			SendBroadcast (mediaScanIntent);
		} 
Example #29
0
        private void ScanForMedia()
        {
            File f          = new File(DIRECTORY_PATH);
            var  contentUri = Android.Net.Uri.FromFile(f);

            var mediaScanIntent = new Android.Content.Intent(Android.Content.Intent.ActionMediaScannerScanFile);

            mediaScanIntent.SetData(contentUri);
            this.SendBroadcast(mediaScanIntent);
        }
        void _list_ItemClick(object sender, ItemEventArgs e)
        {
            var item = (ICursor)_list.Adapter.GetItem(e.Position);
            int id = item.GetInt(item.GetColumnIndex("_id"));
            var intent = new Intent(Intent.ActionView);
            var uri = Uri.WithAppendedPath(ContactsContract.Contacts.ContentUri, id.ToString());

            intent.SetData(uri);
            StartActivity(intent);
        }
    public void OpenBrowser(string url)
    {
      Uri uri = Uri.Parse(url);
      Intent intent = new Intent(Intent.ActionView);
      intent.SetData(uri);

      Intent chooser = Intent.CreateChooser(intent, "Open with");

      this.StartActivity(chooser);
    }
Example #32
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
            Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
            Button callButton = FindViewById<Button>(Resource.Id.CallButton);

            //Disable button
            callButton.Enabled = false;

            //Add code to translate number
            string translatedNumber = string.Empty;

            translateButton.Click += (object sender, EventArgs e) =>
            {
                // Translate user’s alphanumeric phone number to numeric
                translatedNumber = Core.PhoneTranslator.ToNumber(phoneNumberText.Text);
                if (String.IsNullOrWhiteSpace(translatedNumber))
                {
                    callButton.Text = "Call";
                    callButton.Enabled = false;
                }
                else
                {
                    callButton.Text = "Call " + translatedNumber;
                    callButton.Enabled = true;
                }
            };

            callButton.Click += (object sender, EventArgs e) =>
            {
                // On "Call" button click, try to dial phone number.
                var callDialog = new AlertDialog.Builder(this);
                callDialog.SetMessage("Call "+ translatedNumber + "?");
                callDialog.SetNeutralButton(
                    "Call",
                    delegate
                    {
                        // Create intent ti dial phone
                        var callIntent = new Intent(Intent.ActionCall);
                        callIntent.SetData(Android.Net.Uri.Parse("tel:4541139966"));//Call David regardless of actual input //translatedNumber));
                        StartActivity(callIntent);
                    });
                callDialog.SetNegativeButton("Cancel", delegate { });

                // Show the alert dialog to the user and wait for response.
                callDialog.Show();

            };
        }
		void OnLearnMoreClick(object sender, EventArgs e)
		{
			var intent = new Intent();

			//
			// Use ActionView with an http Data value to launch Android's web browser Activity.
			//
			intent.SetAction(Intent.ActionView);
			intent.SetData(Android.Net.Uri.Parse("http://www.xamarin.com"));

			StartActivity(intent);
		}
Example #34
0
        async void TakePhotoButtonTapped(object sender, EventArgs e)
        {
            if (isLoading)
            {
                return;
            }
            camera.StopPreview();
            isLoading = true;
            MessagingCenter.Send <CustomCameraPage>(CustomCameraPage.getInstance(), "StartLoading");

            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()));

                FileStream fileStream = new FileStream(filePath, FileMode.Create);
                await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 50, fileStream);

                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);
                MainActivity.Instance.SendBroadcast(intent);

                Stream stream = fileStream as Stream;

                //MessagingCenter.Send<CustomCameraPage>(CustomCameraPage.getInstance(), "Navigation");
                //MessagingCenter.Send<CustomCameraPage, string>(CustomCameraPage.getInstance(), "PathSend", filePath);

                List <Species> speciesList = await CameraHelper.CommonOperationCameraLibPictures(stream);

                MessagingCenter.Send <CustomCameraPage, List <Species> >(CustomCameraPage.getInstance(), "StreamSend", speciesList);
                //MessagingCenter.Send<CustomCameraPage, Stream>(CustomCameraPage.getInstance(), "StreamSend", stream);

                fileStream.Close();
                image.Recycle();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(@"				", ex.Message);
            }

            isLoading = false;
            MessagingCenter.Send <CustomCameraPage>(CustomCameraPage.getInstance(), "StopLoading");
            camera.StartPreview();
        }
        async void TakePhotoButtonTapped(object sender, EventArgs e)
        {
            camera.StopPreview();

            var image = textureView.Bitmap;

            image = ToGrayscale(image);

            int width = textureView.Width;

            width = width / 2;
            int height = textureView.Height;

            height = height / 2;
            image  = Bitmap.CreateBitmap(image, width - 200, height - 200, 400, 400);
            var x = Task.Run(() => imageClassifier.RecognizeImage(image));

            result.Text = x.Result;
            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);
                MainActivity.Instance.SendBroadcast(intent);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(@"				", ex.Message);
            }

            camera.StartPreview();
            camera.SetPreviewCallback(this);
        }
Example #36
0
        async void TakePhotoButtonTapped(object sender, EventArgs e)
        {
            camera.StopPreview();

            var image = textureView.Bitmap;

            image = Android.Graphics.Bitmap.CreateBitmap(image, (int)OCR_Rectangle.GetX(), (int)OCR_Rectangle.GetY(), 600, 200);
            image = ToGrayScale(image);

            try
            {
                var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath;
                var folderPath   = absolutePath + "/Camera";
                filePath = System.IO.Path.Combine(folderPath, string.Format("photo_{0}.jpg", Guid.NewGuid()));

                String      recognizedText = "???";
                TessBaseAPI baseApi        = new TessBaseAPI();
                baseApi.Init(absolutePath, "eng");
                baseApi.SetImage(image);
                recognizedText = baseApi.UTF8Text;

                OCR_textView.Text = "OCR :" + recognizedText;

                var fileStream = new FileStream(filePath, FileMode.Create);
                await image.CompressAsync(Android.Graphics.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);
                MainActivity.Instance.SendBroadcast(intent);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(@"				", ex.Message);
            }

            camera.StartPreview();
        }
        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";

                //The Folllowing is an answer to quesition that how to Get the selected Crop and Image Name
                Models.CropModel SelectedCrop      = null;
                string           selectedImageName = (MainPage as CameraPage).GetViewModel.Parent.SelectedImagePath;
                FarmerModel      selectedFarmer    = (MainPage as CameraPage).GetViewModel.Parent.SelectedFarmer;
                FieldModel       selectedField     = (MainPage as CameraPage).GetViewModel.Parent.SelectedField;


                var filePath = string.Empty;

                if (!string.IsNullOrEmpty(selectedImageName))
                {
                    filePath = System.IO.Path.Combine(folderPath, string.Format("{0}.jpg", selectedImageName));
                    File.Delete(filePath);
                }

                if ((MainPage as CameraPage).GetViewModel.SelectedCrop != null)
                {
                    SelectedCrop = (MainPage as CameraPage).GetViewModel.SelectedCrop;
                }

                filePath = System.IO.Path.Combine(folderPath, string.Format("NEW_{0}_{1}_{2}.jpg", SelectedCrop.Crop_Name, selectedField.FieldGuid, SelectedCrop.Crop_ID.ToString()));


                //End of



                var fileStream = new FileStream(filePath, FileMode.Create);
                await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 80, fileStream);

                fileStream.Close();
                image.Recycle();
                AndHUD.Shared.ShowToast(activity, "Photo saved!!!", MaskType.Clear, TimeSpan.FromMilliseconds(1500));
                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);
                Context.SendBroadcast(intent);



                await MainPage.Navigation.PopModalAsync();
            }
            catch (Exception ex)
            {
                AndHUD.Shared.ShowToast(activity, "Photo can not taken!!!", MaskType.Clear, TimeSpan.FromMilliseconds(1500));
                System.Diagnostics.Debug.WriteLine(@"				", ex.Message);
            }

            //camera.StartPreview();
        }