Myo android first connection - android

I am very new to android. I am trying to follow this Myo android tutorial
But I am facing a lot of problems since I don't know a lot about android.
My first problem is with placing the sdk , I downloaded it, and it is written that I have to add the SDK as a dependency in my build.gradle file.
When I explored my project, I found 2 build.gradle files as in the image:
So should I add it in which one ?
And how should I add it as an absolute path so I can use the SDK on all devices without changing the path ?
And then they asked me to add these permissions, but where should I add them?
// Required for communicating with the Myo device
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
// Required for sending usage data to Thalmic Labs
<uses-permission android:name="android.permission.INTERNET" />

Q1:So should I add it in which one ?
A:You should add it in the "Module:app" one.
Q2:how should I add it as an absolute path so I can use the SDK on all devices without changing the path ?
A:The path of the SDK doesn't relate to the result,the SDK will be wrapped up in the apk,so don't worry about it.
Q3:Where should I add them (permissions)
A:Add them in AndroidManifest.xml.

Related

Android 10: Delete denied by permission:android.permission.ACCESS_MEDIA_PROVIDER

Target SDK in my project is 31 and when I'm trying to delete a file from DCIM directory, I'm getting following error such as delete denied by permission:android.permission.ACCESS_MEDIA_PROVIDER.
Please consider file path like this: "/storage/emulated/0/DCIM/Screenshots/pic1.jpg"
I have tried so much to find the result every where including stack overflow, but didn't succeeded yet. Even I changed target SDK to lower 30 but not worked.
Following are the solutions that I had already worked on but nothing works:
1.flags in manifest file
android:requestLegacyExternalStorage="true"
android:preserveLegacyExternalStorage="true"
2.permissions in manifest file
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="40"
tools:replace="android:maxSdkVersion" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
Please find the attached code
val fileToDelete = File("/storage/emulated/0/DCIM/Screenshots/pic1.jpg")
fileToDelete.delete()
NOTE: filepath is hardcoded only to explain better
Please find the attached log
2022-03-21 11:22:35.331 8639-20226/com.filepickerdemo D/ContentResolver: delete denied by permission:android.permission.ACCESS_MEDIA_PROVIDER#content://media/external/images/media#_data = ?#/storage/emulated/0/DCIM/Screenshots/pic1.jpg
What else should I put in my code to solve this issue. Thanks in advance.
To delete media files in android 10 and above, You can try contentresolver API.
You need to pass the media's content uri to the 'contentResolver.delete()' method & you will be able to do it easily.
Here is my post on how to do that using Java - Scoped Storage in Android — Writing & Deleting Media Files

How do I deal with the Agora exception "e/agora sdk cannot open log file for writing agorartm.log err=30"?

I use Agora as my RTM(Real Time Messaging) SDK, but after I set it up for Android develop, everything worked fine except for the problem that the RTMClientListener did not automatically update the messages received, and the debug console shows "e/agora sdk cannot open log file for writing agorartm.log err=30". Does anyone know how to fix this? Thanks in advance.
Try this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
The lines above allow Android application read and write permission of external files Add this into AndroidManifest.xml file - before application tag:
package="com.example.yourproject">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application...
Regarding the Agora Flutter app, the example app only works with low security mode Agora projects. Token or primary certificate activated projects won't work with the example app. Go to Agora dashboard, create a new project with low security level - only APP Id type. Then try the example app with the new App id copied from the dashboard of new project.

Flutter APK Build

Goo day friends! I am new to Flutter and I have been experimenting on fetching data via REST API. On Android Studio, everything works just fine, so I suppose there's nothing wrong with my code.
Things I did to make sure my code works:
1.) Run the code in android simulator;
2.) Run the code using real device (enabling USB Debugging).
And it works just fine.
But when I build an apk file out of it and install it on my device, it no longer makes the API call (or is unable to?). I made it so, when the app runs initState(), it waits for the data to be loaded. While the data is not yet available, a CircularProgressIndicator() takes the entire screen.
If I run the app via the installed apk file, it's just CircularProgressIndicator(). Meaning, no data is being loaded and displayed. But when I run the code in AndroidStudio, the data is shown..
I am using http package. I'm not sure what I'm doing wrong, or what I'm missing.
Other things to note: I did not change anything in my AndroidManifest file, and just followed all the steps on building apk file in Flutter through the official documentation.
Like alexsanderfr said, this is indeed most of the time being caused by missing
<uses-permission android:name="android.permission.INTERNET" />
You shouldn't need
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
for REST API.
In Flutter, when debugging you implicitly have access to internet, however in release builds, you need to explicitly declare this permission.
update1
Ensure you have the http-package added to your pubspec.yaml file and that it's properly indented with two spaces:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: ^0.12.0+4
Did you add the internet permission to the manifest? If you're accessing the internet from an Android app you need to add the internet permission over the application tag.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

ionic android : when choose image from gallery the app crash

When I click on choose file(input="file") to choose an image from gallery , after select the image on android the app crash , and also on ios (iphone).
I already add the permissions on the androidmanifest.xml:
<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-feature android:name="android.hardware.camera.autofocus" />
and still not working.
I was getting the same issue in iOS.
Try adding these data to info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera.</string>
For android can you share the logcat output.
How are you building the app, if you don't have Android Studio? Are you using phonegap?
If you have Android Studio, then a tool Monitor is pre installed with Android Studio. When you open Monitor, then the logs for the app can be seen
If phonegap is used, can u share the id, I can take a look if you want
If you only targeting images, I suggest to use the Cordova / Ionic Native plugins instead of using the file input. It will be easier and you will get more control in accessing images and its properties.
You can use either Camera plugin or Photo Library Plugin. You can use the requestAuthorization function to request the permissions from the user.
You may need to add permissions inside your config.xml. For example, as mentioned in the Camera Plugin Ionic's page
[Warning] Since IOS 10 the camera requires permissions to be placed in your config.xml add
<config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist"><string>You can take photos</string></config-file>
Please note that it is always the best idea to have all the permissions inside your config.xml file and not in the AndroidManifest.xml / info.plist, as it will always be added automatically once you add / run your build on the native platforms.

How can you read from the public download directory from unity on an android

I'm trying to read from a file in Unity that I've written to the Downloads folder in Android.
I'm writing the file natively with another apk and I've copied the url that I wrote to: "/storage/emulated/0/Download/file" but when I try File.Exists(thatUrl) it's returning false.
So apparently the permission: <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> means something different in Unity than it does it the native Android SDK. Having that permission allows you to read from the INTERNAL storage as well as the external.

Categories

Resources