Emulator : how to Allow Application to access device location

1,054 views
Skip to first unread message

SK

unread,
Aug 5, 2016, 3:05:35 PM8/5/16
to Android Testing Support Library
While running test on emulator, I always get a pop up to allow application to access device location. How can that be allowed by default whenever the test starts?

Luis Ramirez

unread,
Aug 6, 2016, 6:33:41 PM8/6/16
to SK, Android Testing Support Library
If you're referring to the runtime permission dialog the system shows when you need a permission when targeting API 23 +, you can grant your app the requested permission through adb before your test runs:


What we did is write a simple gradle task that runs the grant permission call on the command line after the install task completes.

On Fri, Aug 5, 2016 at 2:05 PM SK <sana...@gmail.com> wrote:
While running test on emulator, I always get a pop up to allow application to access device location. How can that be allowed by default whenever the test starts?

--
You received this message because you are subscribed to the Google Groups "Android Testing Support Library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-testing-suppo...@googlegroups.com.
To post to this group, send email to android-testing...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-testing-support-library/5a3a7ab2-3238-4395-b940-398bba87961d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Drew Hannay

unread,
Aug 6, 2016, 6:37:29 PM8/6/16
to Android Testing Support Library
You can also pass the -g flag to the adb install command to grant all runtime permissions to the app at install time, which might be a little simpler.


On Saturday, August 6, 2016 at 3:33:41 PM UTC-7, Luis Ramirez wrote:
If you're referring to the runtime permission dialog the system shows when you need a permission when targeting API 23 +, you can grant your app the requested permission through adb before your test runs:


What we did is write a simple gradle task that runs the grant permission call on the command line after the install task completes.

On Fri, Aug 5, 2016 at 2:05 PM SK <sana...@gmail.com> wrote:
While running test on emulator, I always get a pop up to allow application to access device location. How can that be allowed by default whenever the test starts?

--
You received this message because you are subscribed to the Google Groups "Android Testing Support Library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-testing-support-library+unsubscribe@googlegroups.com.
To post to this group, send email to android-testing-support-lib...@googlegroups.com.

Venkata Sesha Giridhar Kari

unread,
Aug 17, 2016, 1:29:28 PM8/17/16
to Android Testing Support Library
You can also use the following in before test method:

getInstrumentation().getUiAutomation().executeShellCommand(
                    "pm grant" + getTargetContext().getPackageName() + "android.permission.ACCESS_COARSE_LOCATION");

Reply all
Reply to author
Forward
0 new messages