简体   繁体   中英

Is there a way to add a permission to an application I'm testing? (my own app)

My application needs that GPS is active at startup as for it to proceed. Iam testing the app, so I'm mocking the GPS by adding <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> to my AndroidManisfest.xml file.

This works ok. But I want to keep things separate. Is it possible to add a permission at runtime when we are testing?

EDIT:

I know from the docs that:

Android has no mechanism for granting permissions dynamically (at run-time) because it complicates the user experience to the detriment of security.

But as a matter of testing the application, is there an alternative?

Thanks

There is no way to add Android permissions at run-time. They must be specified in your manifest.

If you have a separate test application, I believe you only need to put this permission on your test application.

EDIT A test application is really no different to Android than a regular one in terms of permissions. I would just put the permission in your test application's manifest and not worry about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM