Skip to content

Learn Mobile Development

Alamgeer's Blog

Menu
  • Home
  • Privacy Policy
Menu
get device and app informations in maui

How to get Device and App Informations in MAUI

Posted on January 4, 2023January 18, 2023 by Learn Mobile Development

As a mobile apps developer, sometimes we need device and app information like device Model, Manufacturer, OS Version, App Version, Package Name etc. to perform some actions. That’s why in this article i am going to show you how to get device and app Informations in MAUI.

Let’s Start

In this article you will see :

  • What is DeviceInfo?
  • What is AppInfo?

What is DeviceInfo?

  • DeviceInfo is a class in MAUI that allows us to get device information on which our App is running on.

Device information that we can get using DeviceInfo class : 

  • Model – It provides us device model. (eg : iPhone13)
  • Manufacturer – It provides us device Manufacturer. (eg : Apple)
  • Name – It provides us device name. (eg : Alamgeer’s iPhone)
  • VersionString -It provides us os version. (eg : 16.2)
  • Idiom – It provides us types of device on which the application is running on. It can be Phone, Tablet, Desktop, TV, Watch etc.
  • Platform – It provides us device platform. It can be Android, iOS, WinUI, MacCatalyst, Tizen etc.
  • DeviceType – It provides us types of device and identify if we are running the application on an emulator or physical device.

What is AppInfo?

  • AppInfo is a class in MAUI that allows us to get app Information.

App information that we can get using AppInfo class : 

  • Name – It provides us name of the application. (eg : MAUIDeviceAndAppInfoSample)
  • PackageName – It provides us package name or identifier of the application. (eg : com.companyname.mauideviceandappinfosample)
  • VersionString – It provides us the application version. (eg : 1.0)
  • BuildString – It provides us the build number of the version. (eg : 1)
  • RequestedLayoutDirection – It provides the current requested layout direction. (eg : LeftToRight)
  • RequestedTheme – It provides the current requested theme by the system for your application. (eg : Light)

Let’s move to the coding part !!

Setting up the UI

1 – Create a MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="MAUIDeviceAndAppInfoSample.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    BackgroundColor="Black">

    <ScrollView>
        <VerticalStackLayout
            Padding="20"
            BackgroundColor="White"
            Spacing="10">

            <Label
                FontAttributes="Bold"
                FontSize="22"
                Text="Device Informtaion" />

            <Label x:Name="LblDeviceInfo" FontSize="18" />

            <Label
                FontAttributes="Bold"
                FontSize="22"
                Text="App Informtaion" />

            <Label x:Name="LblAppInfo" FontSize="18" />

        </VerticalStackLayout>
    </ScrollView>

</ContentPage>

2 – MainPage.xaml.cs

using System.Text;

namespace MAUIDeviceAndAppInfoSample;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        LblDeviceInfo.Text = GetDeviceInfo();
        LblAppInfo.Text = GetAppInfo();
    }

    private string GetDeviceInfo()
    {
        return new StringBuilder()
            .AppendLine($"Model : {DeviceInfo.Current.Model}")
            .AppendLine($"Manufacturer : {DeviceInfo.Current.Manufacturer}")
            .AppendLine($"Name : {DeviceInfo.Name}")
            .AppendLine($"OS Version : {DeviceInfo.VersionString}")
            .AppendLine($"Refresh Rate : {DeviceInfo.Current}")
            .AppendLine($"Idiom : {DeviceInfo.Current.Idiom}")
            .AppendLine($"Platform : {DeviceInfo.Current.Platform}")
            .AppendLine($"Device Type : {DeviceInfo.Current.DeviceType}").ToString();
    }

    private string GetAppInfo()
    {
        return new StringBuilder()
           .AppendLine($"Name : {AppInfo.Current.Name}")
           .AppendLine($"Package : {AppInfo.Current.PackageName}")
           .AppendLine($"Version : {AppInfo.Current.VersionString}")
           .AppendLine($"Build : {AppInfo.Current.BuildString}")
           .AppendLine($"LayoutDirection : {AppInfo.RequestedLayoutDirection}")
           .AppendLine($"Theme : {AppInfo.RequestedTheme}").ToString();
    }
}

That’s all for now!

You can check the full source code here.

Happy Coding! 😀 

You may also like

StateContainer In MAUI

How to use StateContainer in MAUI

Expander in MAUI

How to use Expander in MAUI

Post Views: 410
Share article with

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I'm Alamgeer Ashraf and having 9+ years of experience in enterprises mobile application development with Xamarin Native, Xamarin Forms & .Net MAUI.

Archives

  • February 2023 (1)
  • January 2023 (9)
  • December 2022 (5)
  • November 2022 (6)

Latest Posts

  • Prevent Dark Mode in Xamarin forms
    How to Prevent Dark Mode in Xamarin formsFebruary 3, 2023
  • apply color to Images
    How to apply color to Images and Icons in MAUIJanuary 30, 2023
  • iOS Large Page Title
    How to set iOS large page title in MAUIJanuary 26, 2023
  • Change StatusBar Color
    How to change StatusBar color in MAUIJanuary 22, 2023
  • Item reordering to CollectionView
    How to apply item reordering to CollectionView GridItemsLayout in MAUIJanuary 18, 2023

Popular Posts

  • How to apply color to Images and Icons in MAUI
  • How to use MediaElement in Xamarin Forms
  • How to use drag and drop gesture to CollectionView in MAUI

Latest Comments

  1. Randyperly on How to use StateContainer in MAUIOctober 18, 2024

    very good _________________ netgame casino бездепозитный бонус

  2. SmiSew on How to use StateContainer in MAUIOctober 10, 2024

    Thanks for the post _________________ pin up casino бест

  3. StavkiTarve on How to use StateContainer in MAUIOctober 7, 2024

    interesting post _________________ слоты в 1xbet приложение

  4. Luke on How to use drag and drop gesture to CollectionView in MAUISeptember 25, 2024

    Thanks very much!

  5. Tony - Nhan Nguyen Lhoa Minh on How to apply item reordering to CollectionView GridItemsLayout in MAUIMarch 28, 2024

    That would be an amazing solution. It's easy to comprehend. Thank you very much.

Our Visitor

0 0 7 8 9 8
Users Today : 2
Users Yesterday : 4
Users Last 7 days : 31
Users Last 30 days : 126
Users This Month : 119
Total views : 14135
How to use UniformItemsLayout in MAUI
Trending
How to use UniformItemsLayout in MAUI

Category

  • .Net MAUI
  • MAUI Community Toolkit
  • MVVM
  • Xamarin Community Toolkit
  • Xamarin Forms

Contact Me

  • LinkedIn
      © 2025 Learn Mobile Development