I'm trying to write a file on a folder outside the app, in the external storage. I have added WRITE_EXTERNAL_STORAGE permission in manifest.
There are similar errors here in Stack Overflow but after trying the solutions (as you will see in my next lines) I'm having the same error.
I tried it in both emulator with Nexus 5X API 27 oreo rom and also in a Huawei real phone with Android 4.4.
In both devices I have the same error:
FileNotFoundException: /storage/sdcard0/Myfile.txt: open failed: EACCES (Permission denied)
This is my code:
String content = "hello world";
File file;
FileOutputStream outputStream;
try {
file = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "MyFile.txt");
outputStream = new FileOutputStream(file);
outputStream.write(content.getBytes());
outputStream.close();
} catch (IOException e) {
Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".activities.Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
For devices with Android >=6.0, you have to request permissions at runtime
For android 4, apprently adding android:maxSdkVersion="18" generate this exception, try by removing it
EDIT : For Android 4.4 and above, you don't WRITE_EXTERNAL_STORAGE IF ONLY you want to write to external storage, from the doc :
beginning with Android 4.4 (API level 19), it's no longer necessary
for your app to request the WRITE_EXTERNAL_STORAGE permission when
your app wants to write to its own application-specific directories on
external storage (the directories provided by getExternalFilesDir())
Elsewere, for android < 4.4, you need to add android:maxSdkVersion="18" for own application-specific directories on
external storage
Just try to request permission with this code :
private void requestPermission() {
ActivityCompat.requestPermissions(getActivity() ,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE ,
Manifest.permission.READ_EXTERNAL_STORAGE} ,
PERMISSION_READ_WRITE_REQUEST_CODE);
}
PERMISSION_READ_WRITE_REQUEST_CODE is the custom variable , in my way is 34.
And handle it in
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode){
case PERMISSION_READ_WRITE_REQUEST_CODE : {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED){
//yeee permission granted
}
}
}
}
Finally yesterday I discovered the same thing that CommonsWare has explained perfectly in the comments:
Get rid of android:maxSdkVersion="18". That is only valid if you are
using getExternalFilesDir(), getExternalCacheDir(), and similar
methods on Context. You are using
Environment.getExternalStorageDirectory(), so you always need
WRITE_EXTERNAL_STORAGE
Related
My fragment is trying to start Camera Activity, but it seems like there is some camera permission problem,
while debugging it goes till below line of code only
startActivityForResult(callCameraApplicationIntent, CAMERA_PIC_REQUEST);
Below is the logcat result
java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=android/com.android.internal.app.ResolverActivity clip={text/uri-list U:content://com.example.tc.provider/external_files/Pictures/photo_saving_app/IMAGE_20191205_070208.jpg} (has extras) } from ProcessRecord{8920903 18662:com.example.tc/u0a343} (pid=18662, uid=10343) with revoked permission android.permission.CAMERA
at android.os.Parcel.readException(Parcel.java:2016)
at android.os.Parcel.readException(Parcel.java:1962)
at android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:4452)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1617)
at android.app.Activity.startActivityForResult(Activity.java:4551)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
Following is the part of code That seems required.
if (Build.VERSION.SDK_INT > 21) { //use this if Lollipop_Mr1 (API 22) or above
Intent callCameraApplicationIntent = new Intent();
callCameraApplicationIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
// We give some instruction to the intent to save the image
File photoFile = null;
try {
// If the createImageFile will be successful, the photo file will have the address of the file
photoFile = createImageFile();
// Here we call the function that will try to catch the exception made by the throw function
} catch (IOException e) {
Logger.getAnonymousLogger().info("Exception error in generating the file");
e.printStackTrace();
}
// Here we add an extra file to the intent to put the address on to. For this purpose we use the FileProvider, declared in the AndroidManifest.
Uri outputUri = FileProvider.getUriForFile(
getActivity(),
BuildConfig.APPLICATION_ID + ".provider",
photoFile);
callCameraApplicationIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputUri);
// The following is a new line with a trying attempt
callCameraApplicationIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
Logger.getAnonymousLogger().info("Calling the camera App by intent");
// The following strings calls the camera app and wait for his file in return.
startActivityForResult(callCameraApplicationIntent, CAMERA_PIC_REQUEST);
Manifest file is below
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tc">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature
android:name="android.hardware.camera.any"
android:required="true" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<!--
Allows Glide to monitor connectivity status and restart failed requests if users go from a
a disconnected to a connected network state.
-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="Login"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths" />
</provider>
</application>
</manifest>
It was working fine previously. I might have done some silly mistake as I am just a learner with help of internet only.
As per the ACTION_IMAGE_CAPTURE documentation:
Note: if you app targets M and above and declares as using the Manifest.permission.CAMERA permission which is not granted, then attempting to use this action will result in a SecurityException.
You do not need the camera permission to use ACTION_IMAGE_CAPTURE on any API level. Therefore, if you are only using ACTION_IMAGE_CAPTURE, you can remove the line <uses-permission android:name="android.permission.CAMERA" />.
If you are using the Camera APIs in addition to using ACTION_IMAGE_CAPTURE, you must request the permission at runtime.
I want to delete files from the SD card root without a file picker.
After searching around for a couple of days,i haven't found a way to do this.But files apps ES file explorer have no problem,does anyone know why that is?
The closest thing i found would be this
How to use the new SD-Card access API presented for Lollipop? but i have to use a file picker
Manifest
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>
<uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
You must provide us some source code and tell what you tried.
Check if you can create new empty files:
File newFile = new File("/storage/sdcard1/test");
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Edit after comment:
Add this in your manifest above application tag.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
I know it may be silly question and I have referred all the similar question before but unfortunately I could resolve this issue. Most probably it is problem in my Manifest.xml file.
When I am trying to access location, app is crashing
here is my manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.tt.test" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".sTest"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.test.tt.test.sService">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </service>
<service android:name="com.test.tt.test.sServiceRequest" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</application>
when I run it throw this error
java.lang.SecurityException: Neither user 11029 nor current process has android.permission.ACCESS_COARSE_LOCATION.
Similar with other permissions. I can not see any mistake in my manifest file. Help appreciated
If you are running on a device on Android Marshmallow and above:
If the device is running Android 6.0 or higher and if the app's target SDK is 23 or higher, the app not just have to list the permissions in the manifest but also must request each dangerous permission it needs while the app is running.
More info:
http://developer.android.com/training/permissions/requesting.html
and
http://developer.android.com/guide/topics/security/permissions.html#normal-dangerous
This means you have some wrong information or malformed info in your menifest file and that is the reason none of your Permission is not identified by your app. Just make sure you have cleaned ANDROIDMANIFEST file with any malformed data.
It will work and all permission should be outside Application tag
move the uses-permission outside application just below the manifest tag
Moving permission section solved my problem with "Neither user or current process has android.permission.READ_PHONE_STATE". Thank you so much to everyone in this forum.
In reference to others, my changes are bellow:
Original:
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<activity android:name=".NfcRead"></activity>
</application>
Change:
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<activity android:name=".NfcRead"></activity>
</application>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
This exception is related to the runtime permission system in Android 6 and above. The Location permission comes under dangerous permission [check here], so you must have to fulfill below 2 minimum requirements to handle these permissions:
Declared below 2 permission in manifest (These permissions must be outside application tag)
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION " />
Check for the granted permission at runtime using checkSelfPermission() and request permissions using requestPermissions() if not already granted.
If you have already done both of the above then and still getting error then check below:
You App's targetSdkVersion (should be >=23) [If the application's targetSdkVersion is set to less than 23. It will be assumed that application is not tested with new permission system yet and will switch to the same old behavior: user has to accept every single permission at install time and they will be all granted once installed].
Check if you have any thing wrong with you manifest file. You might have malformed manifest file.
Check if you are calling any function, that works on location data, before the user Accept/revoked runtime location permission dialog?
Clean you app (Clean build) and re-run.
Hope this may help :-)
I'm working on a simple app that browses through the user's contacts. Unfortunately I keep getting the following error:
java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.HtcContactsProvider2 uri content://com.android.contacts/contacts from pid=27455, uid=10171 requires android.permission.READ_CONTACTS
My manifest file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.helloMaps"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application android:icon="#drawable/icon"
android:label="#string/app_name"
android:debuggable="true">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MapsActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I'm trying to look at my contacts by:
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);
I've tried to add <uses-permission android:name="android.permission.READ_CONTACTS" /> or android:permission="android.permission.READ_CONTACTS" to <application> or <activity>, but both didn't work.
I'm running out of options, does anybody know what I'm missing here?
the <uses-permission> should be contained in the <manifest> element. See Structure of the Manifest File. So trying putting it into <application> or <activity>, won't work. Desperation move: try to move <uses-sdk> before <application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
Also if you can test without the other permissions, remove them.
EDIT: Can you please check if this is your TOP line in your manifest file:
<?xml version="1.0" encoding="utf-8"?>
I was totally stuck on this until I read this article about how permissions are handled starting with SDK 23. The critical hint:
If the application's targetSdkVersion is set to less than 23. It will be assumed that application is not tested with new permission system yet and will switch to the same old behavior: user has to accept every single permission at install time and they will be all granted once installed !
I opened up my gradle.build file and changed targetSdkVersion 23 to targetSdkVersion 22, and now everything works great! I'll eventually find time to build in the new permissions system and switch back to targetSdkVersion 23, which is probably the more correct answer. This is a temporary shortcut.
None of the above helped. The solution is quite simple.
you'll need a runtime permission request.
with or without placing the permission in your manifest, You will need to request that permission from the User on-the-fly.
if( getApplicationContext().checkSelfPermission( Manifest.permission.READ_CONTACTS ) != PackageManager.PERMISSION_GRANTED )
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.READ_CONTACTS}, resultValue);
only then after the approval you will be able to query the contacts phone number/name etc.
Try this in your on create method
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_CONTACTS},1);
I had the same problem and none of the solutions I read helped to resolve it until I added the WRITE_EXTERNAL_STORAGE permission along with the READ_CONTACTS permission.
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I ran into this issue today and none of the above fixes worked for me.
What the issue ended up being had to do with my Eclipse. What I had written in the manifest.xml and what was in the Permissions tab weren't the same. I had the READ_CONTACTS permission in my manifest.xml, but READ_PROFILE was in it's place under my permission's tab.
I know this is an old thread, but hopefully if someone has the same issue I did they'll stumble across this.
Thanks!
I am trying to access HTTP link using HttpURLConnection in Android to download a file, but I am getting this warning in LogCat:
WARN/System.err(223): java.net.SocketException: Permission denied (maybe missing INTERNET permission)
I have added android.Manifest.permission to my application but it's still giving the same exception.
Assuming you do not have permissions set from your LogCat error description, here is my contents for my AndroidManifest.xml file that has access to the internet:
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET" />
<application ...
</manifest>
Other than that, you should be fine to download a file from the internet.
Permission name is CASE-SENSITIVE
In case somebody will struggle with same issue, it is case sensitive statement, so wrong case means your application won't get the permission.
WRONG
<uses-permission android:name="ANDROID.PERMISSION.INTERNET" />
CORRECT
<uses-permission android:name="android.permission.INTERNET" />
This issue may happen ie. on autocomplete in IDE
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.photoeffect"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.example.towntour.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<activity
android:name="com.photoeffect.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
If you are using the Eclipse ADT plugin for your development, open AndroidManifest.xml in the Android Manifest Editor (should be the default action for opening AndroidManifest.xml from the project files list).
Afterwards, select the Permissions tab along the bottom of the editor (Manifest - Application - Permissions - Instrumentation - AndroidManifest.xml), then click Add... a Uses Permission and select the desired permission from the dropdown on the right, or just copy-paste in the necessary one (such as the android.permission.INTERNET permission you required).
Copy the following line to your application manifest file and paste before the <application> tag.
<uses-permission android:name="android.permission.INTERNET"/>
Placing the permission below the <application/> tag will work, but will give you warning. So take care to place it before the <application/> tag declaration.
FOR FLUTTER DEVELOPERS.
Go to
android/app/main/AndroidManifest.xml
Outside the
application tag
but inside the
manifest tag
Add
<uses-permission android:name="android.permission.INTERNET" />
Add the below line in your application tag:
android:usesCleartextTraffic="true"
To be look like below code :
<application
....
android:usesCleartextTraffic="true"
....>
And add the following tags above of application
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
to be like that :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.themarona.app">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
When using eclipse, Follow these steps
Double click on the manifest to show it on the editor
Click on the permissions tab below the manifest editor
Click on Add button
on the dialog that appears Click uses permission. (Ussually the last item on the list)
Notice the view that appears on the rigth side Select "android.permission.INTERNET"
Then a series of Ok and finally save.
Hope this helps
I am late but i want to complete the answer.
An permission is added in manifest.xml like
<uses-permission android:name="android.permission.INTERNET"/>
This is enough for standard permissions where no permission is prompted to the user. However, it is not enough to add permission only to manifest if it is a dangerous permission. See android doc. Like Camera, Storage permissions.
<uses-permission android:name="android.permission.CAMERA"/>
You will need to ask permission from user. I use RxPermission library that is widely used library for asking permission. Because it is long code which we have to write to ask permission.
RxPermissions rxPermissions = new RxPermissions(this); // where this is an Activity instance // Must be done during an initialization phase like onCreate
rxPermissions
.request(Manifest.permission.CAMERA)
.subscribe(granted -> {
if (granted) { // Always true pre-M
// I can control the camera now
} else {
// Oups permission denied
}
});
Add this library to your app
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.tbruyelle:rxpermissions:0.10.1'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
}
That may be also interesting in context of adding INTERNET permission to your application:
Google has also given each app Internet access, effectively removing the Internet access permission. Oh, sure, Android developers still have to declare they want Internet access when putting together the app. But users can no longer see the Internet access permission when installing an app and current apps that don’t have Internet access can now gain Internet access with an automatic update without prompting you.
Source: http://www.howtogeek.com/190863/androids-app-permissions-were-just-simplified-now-theyre-much-less-secure/
Bottom line is that you still have to add INTERNET permission in manifest file but application will be updated on user's devices without asking them for new permission.
You have to use both Network and Access Network State in manifest file while you are trying load or access to the internet through android emulator.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
If you are giving only .INTERNET permission, it won't access to the internet.
** For Activity Recognition like Foot Step Counter
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
** For Internet
<uses-permission android:name="android.permission.INTERNET" />
** For Call Phone
<uses-permission android:name="android.permission.CALL_PHONE" />
[![enter image description here][1]][1]
If you're using Android Studio, hover over the code that requires the permission and click "Add Permission .."
Then you can check the changes in AndroidManifest.xml with git.