getting udid of android emulator - android

I want to get udid of android emulator..How can i get it.Has anyone implemented it before?

Usually you can use TelephonyManager.getDeviceId() to get udid of a device, but if you are using Android emulator, it will return null. Docs here
Update:
You need to require READ_PHONE_STATE permission in your AndroidManifest.xml, i.e., by adding following line in the file:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Related

Why do I get "requesting permission to use WLAN. Allow?" prompt window in real mobile phone?

I use the Code A to set the enabled status of WiFi, it works well when I use Android Emulator with both API 26 and API 23 in Android Studio 3.1.3 , and none of prompt window display!
But I get a prompt window "An App is requesting permission to use WLAN. Allow?" in real mobile phone with Android 5.1 when I run the code A.
How can I make the prompt window not to display in real mobile phone? Thanks!
BTW,the real mobile phone is Samsung SM-J5008 with Android 5.1
Prompt Window
I have set the permissions
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
Code A
fun setWiFi(aWiFiDef: WiFiDef): Unit{
val wifiManager =mContext.applicationContext.getSystemService(WIFI_SERVICE) as WifiManager
wifiManager.isWifiEnabled=aWiFiDef.status
}
Android 5.1 does not have such runtime permission, so I assume, that this is a wrongly implemented permission request rational, which is shown even though the app does not need to. You wrote, that you tested with API level 26 and 23, which is Android 6.0 and higher, so these versions already have runtime permissions. Maybe you haven't seen this issue, because you haven't tested on devices below Android 6.0...
Please check if you somewhere call AppCompat.shouldShowRequestPermissionRationale() and if it is surrounded by SDK level checks or at least with a checkSelfPermission as described here: https://developer.android.com/training/permissions/requesting. Test your code in an emulator with Android 5.1 and Android 6.0. Then you should be able to reproduce that issue also on real phones.
You also need to add this to your manifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
According to the website below: *App on Marshmallow needs ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission and Location services should be enabled to get wifi scan results. Google probably sees scanning for wifi as a security concern, and wanted to add the location permissions as well.
I would recommend following the blog post below if you are having trouble after adding the ACCESS_COARSE_LOCATION permission to your manifest.
https://www.intentfilter.com/2016/08/programatically-connecting-to-wifi.html
EDIT
For the people down voting, please include a comment explaining why. Was my answer flat out wrong? Did I overlook somthing?
Some more information on google's geolocation service:
Google maintains a huge database for its geolocation service ("Access coarse location" permission). It consists of:
Wifi access point mappings: Wifi MAC address resolve to a geolocation
Cell tower mapping: Cell tower ID's resolve to a geolocation
So it is very possible that this user didn't include this permission and is getting this dialog box.

Android Oreo 8.0+ Disable Network Permissions Problems

I'm building a Cordova app that needs to access WiFi on Android and disable the currently connected network in order to prevent automatic disconnection from the network i'm having it connect to (since there is no internet).
The problem is that when testing on Android Oreo 8.0+ I am getting this error in adb logcat and I can't figure out what I need to do to fix this:
E/WifiConfigManager: UID 10315 does not have permission to update configuration "Test SSID"WPA_PSK
E/WifiStateMachine: Failed to disable network
These are the perms listed in manifest:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" />
<uses-permission android:name="android.permission.INTERNET" />
The OVERRIDE_WIFI_CONFIG perm I found on this post, but that doesn't seem to help in my specific situation: Changing Android hotspot settings
I found this specific error located in this file:
https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/master/service/java/com/android/server/wifi/WifiConfigManager.java#984
Which calls canModifyNetwork which I found here:
https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/master/service/java/com/android/server/wifi/WifiConfigManager.java#651
Can anybody more experienced with Android help me to resolve this issue, and what needs to be done in order to allow my app to disable networks?
Does this mean that apps are not allowed to disable a network if it wasn't created by the app?? Please help I don't know where to go from here!
I did find this post as well, which references 6.0, but is this true that we're basically completely locked out of disabling networks we didn't create? Android 6.0 Cannot add WifiConfiguration if there is already another WifiConfiguration for that SSID
I am not able to answer your question per se, but I can answer this
Does this mean that apps are not allowed to disable a network if it
wasn't created by the app?
That's correct, as according the documentation of the method disableNetwork:
Disable a configured network. The specified network will not be a
candidate for associating. This may result in the asynchronous
delivery of state change events. Applications are not allowed to
disable networks created by other applications.
So if the user has already connected to this network using the Android system, in Oreo you won't be able to disable the network.
Though the method disableNetwork returns true or false in the case of success or failure

SecurityException Running on Android with S8 Phone

I get the following exception when running on the new Samsung Galaxy 8 phones. The exception doesn't give me any information about what's causing it (as far as I can tell). I don't have an S8 phone to try to pinpoint the line of offending code.
Does anybody have any idea what the problem is or how to figure it out?
TIA
java.lang.SecurityException:
at android.app.ContextImpl.checkMode(ContextImpl.java:2323)
at android.app.ContextImpl.openFileOutput(ContextImpl.java:534)
at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:192)
at com.yandex.metrica.impl.o.c(SourceFile:178)
at com.yandex.metrica.impl.o.a(SourceFile:44)
at com.yandex.metrica.impl.o$a.a(SourceFile:310)
at com.yandex.metrica.impl.o.b(SourceFile:164)
at com.yandex.metrica.impl.bh.c(SourceFile:139)
at com.yandex.metrica.impl.ag.c(SourceFile:145)
at com.yandex.metrica.impl.ag$a.run(SourceFile:295)
at com.yandex.metrica.impl.ob.bh.execute(SourceFile:10)
at com.yandex.metrica.impl.ob.bj.execute(SourceFile:7)
at com.yandex.metrica.impl.ag.run(SourceFile:86)
It might be due to a lack of permission.
Have you obtained storage permissions?
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Depending on the Android SDK that you are targeting, you might need to request the permission at runtime.
https://developer.android.com/training/basics/data-storage/files.html

SMS sending permission on Active Android device

I'm a newbie with android development. So far I have developed an application which uses SMSManager.
I'm testing my application on an active device when it reaches smsManager.sendTextMessage it throws exception of android.premission.SEND_SMS.
I know that I have to get device permission.
My Question is:
Can I send SMS while uploading application right from IDE, or have to install .apk manually?
You must add the following permissions in your Manifest file:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
If you install the application via debugging/IDE/ADB it will automatically get the permissions you require in your manifest.
So: Yes! When run on the device through the debugger, the application will be able to send test messages.
Bonus information: If you do "stuff" that the application doesn't have the proper permissions for, the debugger will give you exceptions and hints to what is wrong.

can't place call from webpage in android app

I have an app that points the user to a webpage with a phone number in it. But when trying to call from the phone number I get an error message.
For the Android manifest, I tried to request phone permissions with both
<uses-permission android:name="android.permission.CALL_PHONE" />
and
<uses-feature android:name="android.hardware.telephony" android:required="false"></uses-feature>
Neither work.
The error message I get is The web page at tel:(the phone number) might be temporarily down or it may have moved permanently to a new web address.
So what am I missing here?
Ensure that the html link for the phone number is something along the lines of:
Call us now!

Categories

Resources