Features and Permissions
A permission is something an app is allowed to do 🙂
E.g. using the camera, reading location or accessing your contacts.
<uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" android:required="true" />
Internet Access
If your app uses e.g. web-APIs you need internet access. This can be achieved by adding android.permission.INTERNET to your manifest. In this case you need the uses-permission tag.
<manifest package="de.creatronix.sample_app" xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Allows applications to open network sockets.
Allows applications to access information about networks.
Non-TLS APIs
When You have resources which do not use TLS (https but just http) you have to add
<application ... android:usesCleartextTraffic="true"> </application>
Permissions in Services
Checking Permission
import android.content.pm.PackageManager;
int uid = getCallingUid();
int pid = getCallingPid();
Log.d(LOGTAG, "Message from PID " + pid + " UID " + uid);
int perm = mContext.checkPermission("de.creatronix.my_service.MY_PERM", pid, uid);
if (perm == PackageManager.PERMISSION_GRANTED)
Log.d(LOGTAG, "Granted");
else
Log.d(LOGTAG, "Denied");
Enforcing Permissions
mContext.enforceCallingPermission("de.creatronix.my_service.MY_PERM", "echoString permission not granted");
More about permissions:
https://developer.android.com/reference/android/Manifest.permission.html