How to take User permissions in android without declaring it into manifest - java

I want Users READ_CONTACTS and ACCESS_NETWORK_STATE Permission For my app if i Declare this permission On Manifest my app gets Rejected by google play
Manifest file:
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS"
/>
I am using This Code to get network info
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
boolean networkState = activeNetworkInfo != null && activeNetworkInfo.isConnected();
if i remove the permission from manifest file "cm.getActiveNetworkInfo()" this shows error "you need to add permission on Manifest file"
Is Their any other way than manifest file to get the users permission
Kindly help me on this.

It is not possible to request permissions without declaring them in the manifest.
Instead of focusing on removing the permission declarations in the manifest, focus on why Google Play has rejected the app and try to fix the issue.

According to official documentation you must declare permissions in manifest file. You are facing some other issues regarding app submission

Your manifest tells the device and the Play store about your app. You cannot try to skip that. If you really don't need those permissions then don't use it. Otherwise, make an appeal in your Play console if your app has been stopped.
Edit: Read this about Manifest and Google Android Developer Documentation.

Related

Cannot detect location on emulator, Android Studios

I have forked an Android application on Github (https://github.com/android/location-samples/tree/master/BasicLocation) which demonstrates use of Google Play services Location API to get the last known location for a device.
However, when I try and run the application, I receive a Toast message that states "No location detected. Make sure location is enabled on the device."
I have added the following permissions to the Manifest:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
In addition, the Extended controls of the emulator reads my current lat/long coordinates
I was wondering how I can resolve this issue.
Run the google map app and give it all the permissions and after the map show start your app.
check this one for more inf.
Emulator's Location simulation not working

How to display permission request with api 14

I need to display request permission (Read external storage) at run time. without the permission my app crash instantly.
In API 14 you don't need to do a request.
Just put in your manifest above <application> section:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Requesting permissions at run time is not supported with API level 14, it isn't supported until API level 23.
If you're running your app from Android Studio on a device or emulator where the app is already installed, your app will not ask for permission when it runs. If you inadvertently remove the permission you will need to manually grant the permission through the Application Manager on the device or emulator.
To prevent the initial crash, you could wrap the offending call in a permissions check.
if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED) {
// READ DATA
}
Hope this helps!

Google play app change permissions

I have uploaded an application to google play, but it doesn't ask for permissions on install for some reason.
I have these permissions in my AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
You can manually add these permissions via settings on the phone, other permissions do not show up, so I guess app is done correctly, though memory permission is disabled by default and user has to manually enable it.
Most likely, your module has its targetSdkVersion set to 23 or higher. In that case, permissions with a protectionLevel of dangerous — such as the two you are requesting — not only have to appear in the manifest, but have to be requested at runtime.

Oracle MAF and requesting permissions in Android 6.0 (API level 23)

I have an MAF application that uses the devices camera to take a picture. Everything was working fine until I tested it on an S6 running API 23, where it crashed with:
java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=3432, uid=10060 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
As far as I can tell this is because of the way Android are handling permission in the newer API's, noted here:
https://developer.android.com/training/permissions/requesting.html
Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app.
So I followed the instructions on how to request permission during run-time (I've installed Android Support Libraries), the problem is, the method signature looks like this:
int checkSelfPermission (Context context,
String permission)
I cannot find a way to get a reference to the context (the example in the provided link also uses an Activity, same problem there). I just don't have the faintest clue how to do this from within MAF, as it seems Application/Activity objects are not exposed.
I have tried simply extending Activity in one of my classes and attempted to call the checkSelfPermission method with this but then I get run-time errors, after reading up on what an Activity is I understand why this is wrong.
tl:dr
How do we handle the new Android 6 (API level 23) run-time permission requests with oracle's mobile application framework?
Edit:
So as per the discussion in the comments we can see the app is supposed to still function normally on Android 6, even if you're not requesting permissions at run-time.
So I had a look at the AndroidManifest.xml file that MAF is generating on build, and I can see that the permission (from the above exception) android.permission.READ_EXTERNAL_STORAGE is not present:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<permission android:name="com.bsaf.atlas.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.bsaf.atlas.permission.C2D_MESSAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
Also interesting, is that the GPS location does not update either, and the log is constantly posting this:
07-07 02:07:13.089 2174 2174 E LocationProvider: Caught security exception registering for location updates from system. This should only happen in DumpRenderTree.
So my next question is, how do I influence AndroidManifest.xml within MAF? And why is this struggling with location updates?
UPDATE (22/08.2016):
This was actually happening because I was setting the target SDK to 23 in my build configurations. Downloading the new Eclipse simply reset this back to the default (21)
Old Answer:
I solved this by downloading OEPE for Neon (I was using OEPE for Mars).
Oracle Enterprise Pack for Eclipse
The application now correctly generates a popup requesting permission to use the camera.
Please note, this has created an issue with location services and the app crashes when requesting gps location, I have not yet discovered a fix or the source of the problem.

Multiple Permissions in AndroidManifest?

So I was wondering if there is a rule against having more than one "uses-permission" block in my app. EX:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
when I use this in my app, it crashes as soon as i click the button.
NOTE: my button saves a file to the SD card and uploads it to FTP (that's where i'm stuck - adding the internet part)
any thoughts?
It can be as many uses-permissions in a manifest file as required by an application.
You can use-permissions in a Manifest files as per your Requirement , its show the user when it download or install your application then Ask user to require permissions given permissions before Application use.

Categories