sudo nano /etc/modprobe.d/alsa-base.conf
Change this line to
options snd-usb-audio index=-2 to options snd-usb-audio index=1
This will enable USB audio output by default. Reboot now:
sudo reboot
After reboot, To play a sound
aplay -D plughw:1,0 /usr/share/sounds/alsa/Front_Left.wav
if it does not work
cat /proc/asound/modules
Displays:
0 snd_bcm2835
1 snd_usb_audio
aplay -D plughw:0,0 /usr/share/sounds/alsa/Front_Left.wav
aplay -D plughw:1,0 /usr/share/sounds/alsa/Front_Left.wav
Tuesday, September 15, 2015
Wednesday, September 9, 2015
How to get the pid of a process using Java code in Android.
public static String pidOf(String lookFor) {
String line;
String pid=null;
boolean applicationIsOk = false;
Process proc = null;
try {
proc = Runtime.getRuntime().exec("ps");
} catch (IOException e) {
e.printStackTrace();
}
if(proc != null) {
InputStream stream = proc.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
try {
while ((line = reader.readLine()) != null) {
Pattern pattern = Pattern.compile(lookFor);
Matcher matcher = pattern.matcher(line);
if (matcher.find()) {
String[] splited = line.split("\\s+");
if(splited.length>3){
int p = -1;
try {
p = Integer.parseInt(splited[1]);
}catch(NumberFormatException nf){
e.printStackTrace();
}
if(p>0){
pid = new String(splited[1]);
}
}
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
return pid;
}
String line;
String pid=null;
boolean applicationIsOk = false;
Process proc = null;
try {
proc = Runtime.getRuntime().exec("ps");
} catch (IOException e) {
e.printStackTrace();
}
if(proc != null) {
InputStream stream = proc.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
try {
while ((line = reader.readLine()) != null) {
Pattern pattern = Pattern.compile(lookFor);
Matcher matcher = pattern.matcher(line);
if (matcher.find()) {
String[] splited = line.split("\\s+");
if(splited.length>3){
int p = -1;
try {
p = Integer.parseInt(splited[1]);
}catch(NumberFormatException nf){
e.printStackTrace();
}
if(p>0){
pid = new String(splited[1]);
}
}
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
return pid;
}
Subscribe to:
Posts (Atom)