My custom fork of Collect 1.18.1 uses the phone IMEI number - but in a fresh install, calling the PropertyManager function to obtain the IMEI number returns a null value:
String deviceID = new PropertyManager(Collect.getInstance().getApplicationContext()) .getSingularProperty(PropertyManager.withUri(PropertyManager.PROPMGR_DEVICE_ID));
This appears to be because in Settings->Apps, the Permissions screen for Collect, the Telephone permission is not enabled. And if I enable it and rerun the app, I can then obtain the IMEI number using the same function call as above.
I note that when the app is installed (from an apk), the installer tells me that it doesn't need any special permissions. But the first time I run the app, I'm asked to allow it to access photos, media and files on the device - the Storage permission.
But I'm not asked about the Telephone permission, even though READ_PHONE_STATE is included in the Manifest file. And without the Telephone permission being enabled, the IMEI cannot be obtained.
Is there some way to make the app request the Telephone permission when first run, just as it currently requests the Storage permission?
Or if not, is there some way to check the permission before executing the function call, and request and implement authorisation from the user to allow the Telephone permission?
Thanks for any help!