55package io .flutter .plugins .deviceinfo ;
66
77import android .annotation .SuppressLint ;
8- import android .app . Activity ;
8+ import android .content . Context ;
99import android .os .Build ;
1010import android .os .Build .VERSION ;
1111import android .os .Build .VERSION_CODES ;
2121
2222/** DeviceInfoPlugin */
2323public class DeviceInfoPlugin implements MethodCallHandler {
24- private final Activity activity ;
24+ private final Context context ;
2525
2626 /** Substitute for missing values. */
2727 private static final String [] EMPTY_STRING_LIST = new String [] {};
@@ -34,8 +34,8 @@ public static void registerWith(Registrar registrar) {
3434 }
3535
3636 /** Do not allow direct instantiation. */
37- private DeviceInfoPlugin (Activity activity ) {
38- this .activity = activity ;
37+ private DeviceInfoPlugin (Context context ) {
38+ this .context = context ;
3939 }
4040
4141 @ Override
@@ -66,7 +66,7 @@ public void onMethodCall(MethodCall call, Result result) {
6666 build .put ("tags" , Build .TAGS );
6767 build .put ("type" , Build .TYPE );
6868 build .put ("isPhysicalDevice" , !isEmulator ());
69- build .put ("deviceId " , getDeviceId ());
69+ build .put ("androidId " , getAndroidId ());
7070
7171 Map <String , Object > version = new HashMap <>();
7272 if (VERSION .SDK_INT >= VERSION_CODES .M ) {
@@ -87,15 +87,15 @@ public void onMethodCall(MethodCall call, Result result) {
8787 }
8888
8989 /**
90- * Simple call to get the android hardware device Id that is unique between the device + user and
90+ * Returns the Android hardware device ID that is unique between the device + user and
9191 * app signing. This key will change if the app is uninstalled or its data is cleared. Device
92- * factory reset will also result in a value change
92+ * factory reset will also result in a value change.
9393 *
94- * @return The device ID
94+ * @return The android ID
9595 */
9696 @ SuppressLint ("HardwareIds" )
97- private String getDeviceId () {
98- return Settings .Secure .getString (activity .getContentResolver (), Settings .Secure .ANDROID_ID );
97+ private String getAndroidId () {
98+ return Settings .Secure .getString (context .getContentResolver (), Settings .Secure .ANDROID_ID );
9999 }
100100
101101 /**
0 commit comments