I have developed an android application using Android DownloadManager Class. When I try to download file over WiFi working without issue but when I use mobile data downloading not working, showing waiting for network.
This is my code:
DownloadManager.Request request = new DownloadManager.Request(Uri.parse((urlString)));
manifest.xml permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
and this is my reference page: Android DownloadManager example
From what you've provided I can only recommend you to remove the unnecessary code s.a. request.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE); because it by default allows all types of network. Also make sure you haven't set setAllowedOverMetered() and setAllowedOverRoaming() to false.
Related
I was using mock location app for application, now that application is using background tracking enabled and detecting that I am using fake GPS.
I used command tools:node="remove" with below code in manifest file:
{
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission
android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<uses-permission android:name="android.hardware.location"/>
<uses-permission android:name="android.hardware.location.gps"/>
}
However this did not work and application is showing:
please disable fake location app and retry
I want to bypass the device location tracking. Feedback is appreciated.
so I have an existing app that has been on the app store for quite some time, as of 3 days ago I was getting more support enquiries saying my app could not connect to my service.
Now it has finally happened to me on my Android devices - everything works perfectly for iOS, and perfectly for Android on Emulator - but nothing in the real world.
I have looked as far as I can by step-debugging with Cordova and it passes the whitelist test fine. My very first XHR request works fine, but subsequent ones always fail until I completely close the app and re-open.
I am using cordova-plugin-whitelist#1.3.4 - I have also tried cordova-plugin-whitelist#1.0.0
My Content-Security-Policy looks like this
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' gap:; img-src http://*.my-site.com.au https://*.my-site.com.au https://*.my-site.com http://*.my-site.com https://*.googleusercontent.com http://*.googleapis.com https://google.com https://*.google.com https://*.googleapis.com https://*.gstatic.com 'self' data:; style-src http://*.googleapis.com https://*.googleapis.com 'self' 'unsafe-inline'; script-src 'self' https://*.googleapis.com http://*.googleapis.com http://maps.google.com http://*.gstatic.com https://*.gstatic.com https://maps.google.com 'unsafe-inline' 'unsafe-eval'">
My Cordova config has
<allow-navigation href="*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
I have tried adding/removing/replacing the above/every combination with <access origin="*" /> but no luck.
My XHR response always looks like the following
xhr.responseUrl = "http://my-site.com/?d=12343902i49"
xhr.status = 0
xhr.responseText = ""
I have step-debugged the XHR request as far as I could have in the Cordova Plugin, by step debugging out of the Whitelist.java but everything returns fine and it makes it successfully to the line
// If we don't need to special-case the request, let the browser load it.
return null;
of function
WebResourceResponse shouldInterceptRequest(WebView view, String url)
in org.apache.cordova.engine.SystemWebViewClient.java
My Android Manifest has the following
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
I am using Cordova#8.0.0, Cordova platform Android#8.0.0
I've spent several hours trying to dig deeper, what am I missing here? Any help would be greatly appreciated!
As the problem disappears if you lower the targetSDK, it's probably the usesCleartextTraffic mentioned by Nidhin Josehp. It only affects Android 8 or newer devices when targeting SDK 28 or greater.
Instead of manually editing the AndroidManifest.xml as he suggest (you should never manually edit it in Cordova apps) you can add this to the config.xml
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
You might need to change your widget tag in config.xml to look something like this:
<widget id="com.your.app.id" version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
(The addition is the xmlns:android="http://schemas.android.com/apk/res/android")
Try adding android:usesCleartextTraffic="true" to the <application> in the AndroidManifest.xml or as below using config.xml
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
android:usesCleartextTraffic Indicates whether the app intends to use cleartext network traffic, such as cleartext HTTP. The default
value for apps that target API level 27 or lower is "true". Apps that
target API level 28 or higher default to "false". More info
Cleartext is any transmitted or stored information that is not
encrypted or meant to be encrypted. When an app communicates with
servers using a cleartext network traffic, such as HTTP, it could
raise a risk of eavesdropping and tampering of content which is why in latest Android devices, it's set to false by default.
I'm going to jump I swear.
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="26" />
Changed targetSdkVersion to 26 from 28. Worked. But this is going to be a nightmare.
Edit: Problem has come back but only for Samsung Galaxy Tablets. I can't replicate this behaviour anywhere else.
Edit2: Things are...fine again?
Your issues sounds quite similar to what is discussed in Cordova doesn't send origin on request in some Android devices, which refers to a CORS-related issue caused by a bug introduced in Chrome 76 (WebViews based on the same version of WebKit are affected too). Chrome 76 started to be rolled out beginning of August 2019. The problem often disappears if the affected app is restarted but returns randomly.
The corresponding ticket is https://bugs.chromium.org/p/chromium/issues/detail?id=991107. According to the ticket, the problem is fixed in Chrome 76.0.3809.111, which is being rolled out these days.
On your emulator you probably have an older version of Chrome, which might be the reason why the problem doesn't show up there. If you compare affected and unaffected devices and see, that only devices running Chrome in versions >= 76.0 and < 76.0.3809.111 show the symptoms, you probably found the cause of the problem.
If this is the case, you have at least these options:
Wait util the fixed version of Chrome has been rolled out (which might the case already for many affected phones).
If you're in control of the server, you could add the file:// origin to the list of allowed origins there, which is what we did. You have to think about the security implications carefully though.
Btw, after restarting the app, the issue most often disappeared, which makes it hard to debug. We found out, that it can be reproduced by uninstalling and reinstalling the affected app.
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.
i'm using the protocol for making p2p connection using wifi in android (http://developer.android.com/reference/android/net/wifi/p2p/package-summary.html)
I have a problem calling the discoverPeers() function :
ActionListener.onFailure(int reason) is called (its an interface to trigger some events) and i receive reason=1, which means 'P2P_UNSUPPORTED'.
I added all the permissions required and the (use... wifidirect) tag.
i'm using a virtual device and the latest android sdk(4.0.3),
i have an internet connection on this device.
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses permission android:name="android.permission.INTERNET"/>
<uses-feature android:name="android.hardware.wifi.direct" android:required="true"/>
As far as I know you can't run the demo in the emulator because it doesn't support real Wifi.
You should launch the demo on a real device like the Galaxy Nexus which supports ICS and Wifi-Direct.
facepalm Yea...I was running on an emulator instead of the real deal...works fine if you use a device that ACTUALLY has Wifi...ha!
I am making a game with in-app purchasing for extra levels. I have implemented all of the necessary code and the test purchases work perfectly. However when I go to add the products to my (unpublished) app I get the following message on the android developer dashboard:
"New in-app products cannot be added because the current application version does not use the BILLING permission."
These are the permissions I have:
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.com.android.vending.BILLING" />
<uses-permission android:name="android.permission.BILLING" />
So I can't understand why I am getting this message. Any help would be greatly appreciated, I am trying to release the game this weekend and this is my last barrier.
Thanks in advance, and rest assured I WILL accept an answer, I know people on here get worried about that sometimes.
The problem is with the permission. Use
<uses-permission android:name="com.android.vending.BILLING" />
It looks like your app gets all the permissions it needs. My advice is to make sure that the uploaded version of the app is the current version, and also that you are logged in using your Google Checkout Merchant account (this is different from a regular Google or Google Checkout account) as referenced By the docs. Hope this helps!