Home > Net >  Why does AndroidId have a different result between Android and Xamarin
Why does AndroidId have a different result between Android and Xamarin

Time:12-04

I have the need to detect a common factor between two apps, one written in Xamarin and one written in Java (Android Studio), running on a users phone.

In the good old days the IMEI did the job nicely. However now I am having to use the Device ID, which is fine for the current purpose, but not perfect.

Anyway, using the following statement in Xamarin gives one result, while using the statement that follows this in Android, gives a different result, both on the same phone.

Why would this be, why is the Device ID not reported as the same value, and is there a way to identify the DeviceID via both platforms that result in the same output ?

Thanks

Xamarin code - Result is "a70c996e74002942"

var Device_ID = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId);

Android Studio code - Result is "702669b2e9a6f7d1"

String Device_ID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);

CodePudding user response:

From the docs

unique to each combination of app-signing key, user, and device

For privacy reasons, two different apps on the same device will have different ids

CodePudding user response:

AndroidId is a unique identifier for an Android device. It is used to identify the device for various purposes, such as for app installation and for tracking advertising.

In Android, the AndroidId is typically generated by the device manufacturer and is stored in the device's system settings. It is intended to be a unique and persistent identifier for the device that remains constant even if the device is factory reset or the user changes their Google account.

In Xamarin, the AndroidId is generated differently. Xamarin is a cross-platform mobile development framework that allows developers to build Android and iOS apps using the .NET programming language. In Xamarin, the AndroidId is generated by the Xamarin runtime, rather than by the device manufacturer. As a result, the AndroidId generated by Xamarin may be different from the AndroidId generated by the device itself.

In general, the difference between the AndroidId generated by Android and the AndroidId generated by Xamarin should not cause any issues. However, if you are using the AndroidId for a specific purpose, such as for app installation or for tracking advertising, you may need to account for the difference in the AndroidIds generated by Android and Xamarin. You can do this by using a different identifier, such as the device's serial number, or by checking for both the Android and Xamarin AndroidIds and using the appropriate one for your purposes.

CodePudding user response:

With the value of the mobile app market breaking $189 billion in 2020, a decision like Xamarin vs. React Native can have a notable impact on businesses engaging in mobile app development.

Both Xamarin and React Native allow developers to create performant non-native apps. Based on the comparison points below, React Native has a slight advantage over Xamarin.

Performance Popularity Community & Developer Ecosystem Development Environment Availability Compilation Costs To further analyze Xamarin vs. React Native and understand how two frameworks with the same intention express themselves differently.

  • Related