.NET MAUI
Device Features & Essentials
7 question(s)
How do you get the device's geolocation in MAUI?
Beginner
Use Geolocation.Default.GetLocationAsync (last-known or a fresh request with GeolocationRequest specifying accuracy and timeout). Request location permission first. GetLastKnownLocationAsync is faster but may be stale; GetLocationAsync forces a fix.
var request = new GeolocationRequest(GeolocationAccuracy.Medium,
TimeSpan.FromSeconds(10));
var loc = await Geolocation.Default.GetLocationAsync(request);
Real-world example
A weather app fetches the user's coordinates to show local conditions after requesting location permission.
Common follow-ups: Last-known vs fresh location? | What permission is required?
Geolocation
Permissions
Device Features & Essentials
How do you pick or capture a photo in MAUI?
Beginner
Use MediaPicker.Default.PickPhotoAsync to choose from the gallery or CapturePhotoAsync to use the camera (camera requires permission and hardware). Both return a FileResult you can open as a stream to display or upload.
var photo = await MediaPicker.Default.CapturePhotoAsync();
if (photo is not null)
{
using var stream = await photo.OpenReadAsync();
// save or display
}
Real-world example
A profile screen lets users take a new avatar photo or pick an existing one with a couple of lines.
Common follow-ups: Does capture need permission? | What does PickPhotoAsync return?
Media
Permissions
Device Features & Essentials
How do you open the browser, dialer, or email from MAUI?
Beginner
Use the launcher/communication APIs: Browser.Default.OpenAsync for URLs, PhoneDialer.Default.Open for phone numbers, Email.Default.ComposeAsync for email, and Sms/Map for others. These invoke the platform's default apps rather than embedding them.
await Browser.Default.OpenAsync("https://w3teacher.com",
BrowserLaunchMode.SystemPreferred);
PhoneDialer.Default.Open("+15551234567");
Real-world example
A contact screen opens the dialer with the support number and launches the website in the system browser.
Common follow-ups: SystemPreferred vs External mode? | How do you compose an email?
Launcher
Communication
Device Features & Essentials
How do you read device sensors like the accelerometer?
Intermediate
Use the sensor APIs (Accelerometer, Gyroscope, Compass, Barometer). Subscribe to ReadingChanged and call Start with a SensorSpeed, then Stop when done to save battery. Marshal UI updates to the main thread.
Accelerometer.Default.ReadingChanged += (s, e) =>
Debug.WriteLine(e.Reading.Acceleration);
Accelerometer.Default.Start(SensorSpeed.UI);
Real-world example
A fitness app detects shakes and step motion by reading the accelerometer at UI speed and stopping it when the screen closes.
Common follow-ups: Why stop sensors when idle? | What is SensorSpeed?
Sensors
Performance & Optimization
Device Features & Essentials
How do you get device and display information in MAUI?
Intermediate
Use DeviceInfo (model, manufacturer, platform, version, idiom, DeviceType—physical vs virtual) and DeviceDisplay (screen metrics, density, orientation, keep-screen-on). These help adapt UI and diagnose device-specific issues.
var idiom = DeviceInfo.Current.Idiom; // Phone/Tablet/Desktop
var density = DeviceDisplay.Current.MainDisplayInfo.Density;
DeviceDisplay.Current.KeepScreenOn = true;
Real-world example
A video page keeps the screen awake during playback and adapts controls when it detects a tablet idiom.
Common follow-ups: How do you detect an emulator? | What is display density?
Device Info
Responsive UI
Device Features & Essentials
How do you use the Clipboard and Share APIs?
Intermediate
Clipboard.Default.SetTextAsync/GetTextAsync copies and reads text. Share.Default.RequestAsync opens the OS share sheet with text or files (ShareTextRequest/ShareFileRequest), letting users send content to other apps.
await Clipboard.Default.SetTextAsync(couponCode);
await Share.Default.RequestAsync(new ShareTextRequest
{ Text = "Check this out!", Title = "Share" });
Real-world example
A coupon screen copies the code to the clipboard and offers a Share button to send a referral link to friends.
Common follow-ups: How do you share a file? | Is Clipboard access async?
Clipboard
Sharing
Device Features & Essentials
How do you run background work or scheduled tasks in MAUI?
Advanced
MAUI has no unified background API; use platform mechanisms: Android WorkManager/foreground services, iOS BGTaskScheduler/background modes, and Windows background tasks—wrapped behind a shared interface. For short async work while active, normal tasks suffice; true background execution needs native scheduling per platform.
public interface IBackgroundSync { void Schedule(TimeSpan interval); }
// Platforms/Android -> WorkManager; Platforms/iOS -> BGTaskScheduler
Real-world example
A messaging app schedules periodic sync via WorkManager on Android and BGTaskScheduler on iOS behind one IBackgroundSync interface.
Common follow-ups: Why is there no unified background API? | What handles Android background work?
Background Tasks
Platform Integration
Device Features & Essentials