Sound capture. MacOS permissions. Java Audio API - java

I'm trying to capture sound from microphone via Java Sound API.
I'm using sample code from github and it works perfect on Windows system, but when it runs on MacOS - audio-line buffer returns zero-bytes.
Also if I compile project to jar and run it via administrator permission - appears a message to give access to microphone and after I grant it - all works.
So the question is how to make permission request from code and run app without sudo?
Thanks!

BTW, you have to use the default terminal that comes with mac to execute jar file. That will worked.
The third party terminal, such as iTerm, it's not ok.

Related

Missing permission to access input devices on Raspberry Pi3 B+

I have written a javafx/java program to run on my Raspberry Pi 3B+ with 7" official touchscreen. I managed to get the software to run on my PCs, installed the javafx extension for my jdk on the pi and now I'd be ready to run it. Unfortunately when I do I get the following error in the console:
Udev: Failed to write to /sys/class/input/input3/uevent
Check that you have permission to access input devices
Cannot open display
I have no idea how to fix that. I tried sudo adduser man input, which added man to the group input, but I still get the same error.
Do you know what I need to do to acces the Touchscreen?

Android Studio: Using an external executable

I would like to use an external executable within my android app.
It is distributed for different platforms and under windows it's a console program that can be used in this way
For Android the executable is called senpai-arm. I moved it to an Android folder and tried to start it in a similar way to the link above but it won't start.
String storage = context.getFilesDir().getAbsolutePath();
// Create the proccess in JAVA
Process proc = Runtime.getRuntime().exec(storage+ "/senpai-arm");
error message below:
java.io.IOException: Error running exec().
Command: [/data/user/0/com.example.jp.fanfar/files/senpai-arm] Working Directory: null Environment: nul
cause: Permission denied
Sorry that I didn't observe the cause Permission denied in my original question.
I rephrase my question a bit.
Is it possible to start a program like this?
What permissions do I need? I have read/write external storage permission.
(I have the source code in C++ and read about NDK but I was hoping to take a shortcut by using the distributed executable instead.)

AVD not running

Today when I was doing my project using android studio, a blue screen suddenly appears and system get restarted automatically. And now when I tried to run my app using emulator, the AVD is not running and I get an error as below. Anyone faced this before ? How do I fix this?
ProcessNotCreatedException: Unexpected error while launching AVD:
Cannot run program
"C:\Users\tongws\AppData\Local\Android\sdk\tools\emulator.exe":
CreateProcess error=216, This version of %1 is not compatible with the
version of Windows you're running. Check your computer's system
information to see whether you need a x86 (32-bit) or x64 (64-bit)
version of the program, and then contact the software publisher
Wnen I click the Android Device Monitor, nothing happen also...
Found the following solution.
Go to the following directory in your computer:
C:\Users.android\avd
Inside this directory you will find all files and directories with the definition and content of your avd machines-
Now do the basic troubleshooting steps:
-check if the avd directory exists and if it contains a file with the name "sdcard.img".
-if the file exists, try to rename it (to check if its locked) and then go to eclipse and ask to create a new sd card.
-if it fails, try to create manualy a file with that name to check premissions.
good luck
You have a computer problem not related to AVD
ProcessNotCreatedException :Exception thrown when attempting to retrieve the result of a task that aborted by throwing an exception.
Because of their usefulness and ubiquity, EXE files are commonly used
as a method of delivery for virus / malware infection. Often, viruses
will be disguised as a benign EXE file (such as emulator.exe) and
distributed through SPAM email or malicious websites, which can then
infect your computer when executed (eg. when you double-click the EXE
file). In addition, viruses can infect, replace, or corrupt existing
EXE files, which can then lead to error messages when
related programs are executed. Thus, any executable files that you
download to your PC should be scanned for viruses before opening -
even if you think it is from a reputable source.
Read SO Answer .
What should you do
FORMAT Your System
Install Android Studio (Set Latest Version With Proper JDK Path)Note that you need to have JDK 6 or higher installed.
You can use Intel x86 Emulator Accelerator (HAXM installer) or Genymotion .
IF YOU HAVE MULTIPLE DRIVES, THE DRIVE WHERE THE OS IS INSTALLED IS
NEEDED TO BE FORMATTED, SO YOU SHALL LOSS ALL DATA OF THAT DRIVE. I
SUGGEST YOU TO TAKE A BACK UP OF ALL YOUR IMPORTANT DATA STORED IN
THAT DRIVE, INTO OTHER DRIVES WHICH WOULD REMAIN UNCHANGED. ON THE
OTHER HAND, IF YOU HAVE ONLY ONE DRIVE, THEN ALL YOUR DATA WILL GET
ERASED WHILE FORMATTING .

Executing adb command on java program

i made a java tool which calls certain adb command to download an app from market. When i made it into a runnable JAR, its executing fine in the system where i made it, but when i try it on other system the adb commands just fail to execute
Any suggestions
AFAIK executable jar donot work on android. Sun Java and Android are not compatible
Have you included the Adb executable and the related dll in your solution?
You should include it for 2 main reasons:
if the system hasn't the android sdk, it doen't have adb
the path to adb can differ from one computer to another.

Change file permissions in DDMS (Android)

I'm trying to test the behavior of my application when it cannot access some files due to missing permissions.
Is it possible to change file/folder permissions on an android emulator using FileExplorer in DDMS perspective?
To change permissions in the emulator you need to use the adb shell command from your adroid-sdk platform-tools. In the android shell you can enter the command su to get root access. Now you can see and change the permissions with the normal unix commands chmod
Note, that the system folder in Android is mounted read-only. You would have to remout it read-write after this tutorial:
http://android-tricks.blogspot.com/2009/01/mount-filesystem-read-write.html
Be careful in anyway to use only writable filesystems like /data or sdcardfor your application data since using restricted folders can have negative side effects in a productive environment!

Categories

Resources