Failed to read the device model, manufacturer information

CTCHANGCTCHANG AUMember ✭✭

Hi,

I recently I have an transient problem on reading the device model, manufacturer and user information from the Android.OS.Build library as below,

`
public string DeviceName
{
get
{
// read and return current device name
return string.IsNullOrEmpty(Android.OS.Build.User) ? string.Empty : Android.OS.Build.User;
}
}

    public string DeviceModal
    {
        get
        { 
            // read and return current device model
            return string.IsNullOrEmpty(Android.OS.Build.Model) ? 
                string.Empty : 
                    Android.OS.Build.Model.StartsWith(Android.OS.Build.Manufacturer) ? 
                        Android.OS.Build.Model : 
                        string.Format("{0} {1}", Android.OS.Build.Manufacturer, Android.OS.Build.Model);
        }
    }

`

Does anyone having the same problem? The same code used to work when I compiled my code with MonoDevelop. Now the same code no longer work in the latest sdk with Xamarin Studio.

Regards,
Hackzai

Posts

  • Try to use in this way it worked for me:

    public string DeviceModal
    {
    get
    {
    // read and return current device model
    return string.IsNullOrEmpty(global::Android.OS.Build.Model) ?
    string.Empty :
    global::Android.OS.Build.Model.StartsWith(global::Android.OS.Build.Manufacturer) ?
    global::Android.OS.Build.Model :
    string.Format("{0} {1}", global::Android.OS.Build.Manufacturer, global::Android.OS.Build.Model);
    }
    }

    :)

  • ArnoldBoschArnoldBosch ZAMember ✭✭

    here's a method that returns manufacturer and model

    public string getDeviceName() { string manufacturer = Build.Manufacturer; string model = Build.Model; if (model.StartsWith(manufacturer)) { return capitalize(model); } else { return capitalize(manufacturer) + " " + model; //"Samsung GT-N8010" } }

Sign In or Register to comment.