I am accessing the JSON webServices but it is not running and it is showing execption.
I made a activity and calling the services from this activity class, when i run from java code services running fine but not running in android....what could be the reason behind this?
I am following standard code of calling from another project, also the services running in that project but not on mine. thanks.
Add permissions to access internet before calling services,
add following lines to your menifest files.
<uses-permission android:name="android.permission.INTERNET">
</uses-permission>
check and tell if still there any problem
Related
I'm having a strange problem with my application. I made a very simple app to request car parts for a garage. The user (the garage's automobile mechanics) put the parts that he need in the app and a computer (that is in another part of the garage) receives the order and prints directly to a thermal printer. I send the data via an HTTP post, very simple, I just send the JSON to an HTTP address.
The problem is: when I run the debug version (via "flutter run" command on vscode) it runs perfectly, but when I generate the apk (via "flutter build apk") the app runs but it doesn't send the HTTP post (there are no error messages, the app just don't send and stays in the same screen forever). I have tested different devices, they all worked normally with the debug version, created and installed directly from vscode, and didn't work with the release app.
Why does it happen? Since the debug and the release apk have the same code shouldn't work the same way? Is there any way to see a log (some kind of debug, I don't know) running the release version?
This issue is most likely related to the permissions. Please check if your AndroidManifest.xml file in Android > app > src > main directory has the following permission:
<uses-permission android:name="android.permission.INTERNET"/>
If the permission isn't present, add it above the line that starts with <application:
<uses-permission android:name="android.permission.INTERNET"/> // Add here
<application
android:name="io.flutter.app.FlutterApplication"
The solution posted by Joao Soares worked, but i still have a question: why?
Is this the standard behavior of the app? The permission to use the internet is really off by default? I can't see a reason for this...
Well, hello..
I have a question, how would you correctly use this
"ActivityManager.killBackgroundProcesses(String packageName)"
I have tried to replace packagename with a package, for now let's call it com.example.package.
It doesn't seem to be compiling it as it pops up with errors (I am new to Android app developing)
Would appreciate any help! =)
You must have a special permission to kill background processes from your application. Add the following permission in your manifest.
"uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"
The above permission enables to kill any background process running for the package name provided in "ActivityManager.killBackgroundProcesses(String packageName)"
I'm trying to run a service by using following code:
Intent i = new Intent(getApplicationContext(),MyService.class);
startService(i);
This code works fine on versions older than Android 6.0 Marshmallow. But here on Android 6.0, the service never gets created. startService() is returning null. I'm calling it from an Activity in the same package. My manifest is like:
<service
android:name="com.example.app2.MyService"
android:label="#string/app_name">
</service>
Also my application is not crashing, it's just the service is not starting (not created).
Once I was having the same problem. It was a very small and stupid mistake. I had given <service> tag outside <application> tag in manifest.xml. After moving it inside <application> tag service started successfully. Check for any typos in service name also. Hope it helps!
If you are accessing any device hardware features(Camera, Storage, Location etc) in the Service. You need to ask runtime permission in the Marshmallow devices. Otherwise, it will make a crash if your compile SDK version >=23. Please paste your Crash log or Service code for further clarification.
Please check the link to implement the feature:
https://developer.android.com/training/permissions/index.html
https://developer.android.com/training/permissions/requesting.html
I've got this strange error when building my project in Android Studio. Basically my app uses GPS to get the current location of the user.So in my androidmanifest.xml i've placed this line:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
But when building the app,this exception keeps popping up:
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.SecurityException: Provider gps requires ACCESS_FINE_LOCATION permission
When using the networkprovider for the lastKnownLocation, the app works fine (and will most likely use another permission).
EDIT: the permissions tag is not within the Application tag.
Does anyone recognize this error?
Place it outside application tag.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<application.....
Make sure the uses-permission element is not inside the application element. Android Studio will not show any problem in this case.
OK, I've now rebuild the entire manifestfile and the error is gone. But essentially this is just a 1:1 copy of the old manifest file. So it's still a mystery what caused the error in the first place.
Thanks for all the help and advice!
Part of my application, I create an Android Service, which encapsulate a Native code library. The Android Service is running in its own process.
I need the Native code from the Android service to access and write in the private data from the installation folder (/data/data/package folder).
Is that possible?
Looks like the native code is getting a Write Access error.
In the same line, can this Service access the SD Card directory at "/mnt/sdcard/Android/data/ ?
It looks also that the native code gets an access error.
Any confirmation will help
thanks
eric
For both questions: Yes.
Your Service is part of your application, same process as Activities and other parts of app. It can access app's private folder, correctly determined by:
getPackageManager().getPackageInfo("com.example.app", 0).applicationInfo.dataDir;
Also it can write to SD card, assuming you have permission in manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
You probably wrongly assume that your service runs in different process than rest of app. It's still the same process, native code doesn't make difference.