Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            imageViewHelper = new ImageViewHelper(this);

            SetContentView(Resource.Layout.Storage);

            loadPhotoButton = FindViewById <Button>(Resource.Id.loadPhotoButton);
            createDocButton = FindViewById <Button>(Resource.Id.createDocButton);

            if (bundle != null)
            {
                currentImageUri = Android.Net.Uri.Parse(bundle.GetString("current_image_uri", string.Empty));
            }
            else
            {
                currentImageUri = null;
            }

            // This button lets a user pick a photo from the Storage Access Framework UI
            loadPhotoButton.Click += (o, e) =>
            {
                // I want data from all available providers!
                Intent intentOpen = new Intent(Intent.ActionOpenDocument);

                // filter for files that can be opened/used
                intentOpen.AddCategory(Intent.CategoryOpenable);

                //filter results by mime type, if applicable
                intentOpen.SetType("image/*");
                StartActivityForResult(intentOpen, read_request_code);
            };

            // This button takes a photo and saves it to the Storage Access Framework UI
            // The user will be asked what they want to name the file,
            // and what directory they want to save it in

            createDocButton.Click += (o, e) =>
            {
                Intent intentCreate = new Intent(Intent.ActionCreateDocument);
                intentCreate.AddCategory(Intent.CategoryOpenable);

                // We're going to add a text document
                intentCreate.SetType("text/plain");

                // Pass in a default name for the new document -
                // the user will be able to change this
                intentCreate.PutExtra(Intent.ExtraTitle, "NewDoc");
                StartActivityForResult(intentCreate, write_request_code);
            };
        }
Exemplo n.º 2
-1
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			imageViewHelper = new ImageViewHelper(this);

			SetContentView(Resource.Layout.Storage);

			loadPhotoButton = FindViewById<Button>(Resource.Id.loadPhotoButton);
			createDocButton = FindViewById<Button>(Resource.Id.createDocButton);

			if (bundle != null)
			{
				currentImageUri = Android.Net.Uri.Parse(bundle.GetString("current_image_uri", string.Empty));
			}
			else
			{
				currentImageUri = null;
			}

			// This button lets a user pick a photo from the Storage Access Framework UI
			loadPhotoButton.Click += (o, e) =>
			{

				// I want data from all available providers!
				Intent intentOpen = new Intent(Intent.ActionOpenDocument);

				// filter for files that can be opened/used
				intentOpen.AddCategory(Intent.CategoryOpenable);

				//filter results by mime type, if applicable
				intentOpen.SetType("image/*");
				StartActivityForResult(intentOpen, read_request_code);

			};

			// This button takes a photo and saves it to the Storage Access Framework UI
			// The user will be asked what they want to name the file, 
			// and what directory they want to save it in

			createDocButton.Click += (o, e) =>
			{
				Intent intentCreate = new Intent(Intent.ActionCreateDocument);
				intentCreate.AddCategory(Intent.CategoryOpenable);

				// We're going to add a text document
				intentCreate.SetType("text/plain");

				// Pass in a default name for the new document - 
				// the user will be able to change this
				intentCreate.PutExtra(Intent.ExtraTitle, "NewDoc");
				StartActivityForResult(intentCreate, write_request_code);
			};
		}