How to unmute the master control? - java

I've been attempting to unmute the computer by using a simple java application. However, when I try to do something like:
final Line line = AudioSystem.getLine(Port.Info.SPEAKER);
line.open();
BooleanControl muteControl = (BooleanControl) line.getControl(BooleanControl.Type.MUTE);
muteControl.setValue(false);
It does not work. Can anyone lead me in the right direction/
Thanks,
-Jaccob.

Line doesn't provide a setter for this property, you just can't turn on/off the main line that way AFAIK.
IMHO it's may be better that way: I don't know what app you're writing, but as a user, I hate when an application plays with my speaker ^^

Related

What command do I use to fix this problem?

My main goal is to create a program that can automate an android app to do everything you would with your fingers.
I wrote this line of code so that if that switch is turned ON, the code will switch it OFF.
driver.findElement(By.id("com.offerup:id/shipping_checkbox")).click();
But when I run my code again, that switch is now OFF by default.
I need a command that leaves the switch alone if it is already OFF.
Does anyone know what command to use?
You need to check whether the switch is ON or not. You could achieve this using the following code:
if(driver.findElement(By.id("com.offerup:id/shipping_checkbox")).isSelected()){
driver.findElement(By.id("com.offerup:id/shipping_checkbox")).click();
}
Updated:
As mentioned by Muzammil, isSelected() is not working as expected. Alternatively, you could use the checked attribute:
MobileElement shippingCheckbox= driver.findElement(By.id("com.offerup:id/shipping_checkbox"));
if(shippingCheckbox.getAttribute("checked").equalsIgnoreCase("true")){
shippingCheckbox.click();
}
There are 2 ways to check slider is on or off.
This is Node details of Slider.
Option-1: By using text
Here we will click only if slider is On.
MobileElement sliderElement=driver.findElement(By.id("com.offerup:id/shipping_checkbox"));
String sliderStatus = sliderElement.getText();
if (sliderStatus.equalsIgnoreCase("On")) {
sliderElement.click();
}
Option-2: By using Attribute
Here we will click only if slider is On.
MobileElement sliderElement=driver.findElement(By.id("com.offerup:id/shipping_checkbox"));
String sliderStatus=sliderElement.getAttribute("checked");
if (sliderStatus.equalsIgnoreCase("true")) {
sliderElement.click();
}
}
Edit: I made a mistake in reading this, and missed that it was an Android app, so Javascript is likely unavailable. This comment will only help someone with the same issue on web browser testing, or any situation where Javascript can be executed on the application.
Additional possibility for checking. Not that it is superior to other options.
using OpenQA.Selenium.Support.Extensions;
string selector = "com.offerup:id/shipping_checkbox";
if(driver.ExecuteJavascript<bool>($"return document.getElementById('{selector}').checked")) {
driver.findElement(By.id($"{selector}")).click();
}

Java Discord bot, #mention a user?

There doesn't seem to be much about this on google aside from advising to use their userID (a string of numbers) instead of their name.
I enabled dev mode to grab their ID and tried the below however it just comes out as a plain text message with no #mention.
chan.sendMessage("Hey #299059199160352768 are you there?").queue();
Any ideas?
Just add an opening and closing angle bracket. <#id>. So your string would look like
chan.sendMessage("Hey <#299059199160352768> are you there?").queue();

ImageJ classes used to analyze

I'm developing a ImageJ plugin that It works in my desktop pc but in my laptop it doesn't.
For this reason, now I'm trying to improve and I want to modify the next steps but i can't get it. This is the code:
IJ.selectWindow("example");
IJ.run("Convert to Mask");
IJ.run("Fill Holes");
IJ.run("Set Scale...", "distance=1 known="+pixelSize+" pixel=1 unit=um");
IJ.run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Masks display clear record");
I known that "Analyze Particles" I must to use the ParticleAnalyzer class (I dont sure how to do but... I'm researching the class) but for the other steps I can not find solution.
I hope that someone can help, thank you.
Best Regards.
I didn't get what I wanted it but I left to use the windows and now I am using ImagePus variables and It works better. I put the code:
IJ.run(this.cMask, "Convert to Mask", "");
IJ.run(this.cMask, "Fill Holes","");
IJ.run(this.cMask, "Set Scale...", "distance=1 known="+pixelSize+" pixel=1 unit=um");
IJ.run(this.cMask, "Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 display clear record");

Android SDK, Check if device is Amazon-FireTV

I am trying to write a simple piece of code that will execute some other code if true. What I want to do is check if my app is running on the 'Amazon Fire-TV (BOX, not the Fire-TV stick)' I think it would not be that hard to do but I am guessing it would be something like this?
String osName = android.getSystemOS();
if(!osName.equals("AMAZON FIRE-TV")){
Toast.makeText(MainActivity.class, "This app may not be compatible with your device..., Toast.LENGTH_LONG").show();
...
}
You can check any device name specifically using:
boolean isFireTV = Build.MODEL.equalsIgnoreCase("AFTB");
(see this page for FireTV model strings, and this one for Fire Tablets)
I'd also check out this answer for a more generic test to help you determine if your app is running on an Amazond device, or installed via the Amazon AppStore (eg on a Blackberry device)
the following function:
public static boolean isTV() {
return android.os.Build.MODEL.contains("AFT");
}
should detect either firetv or fire tv stick
see
https://developer.amazon.com/public/solutions/devices/fire-tv/docs/amazon-fire-tv-sdk-frequently-asked-questions
for details

How can I play Alert.startAudio() through the phone speaker?

I need to play Alert.startAudio() through the loudspeaker of a Blackberry device instead of the headset.
I know that I can change the Audio path through the AudioPathControl interface, but I don't know how to get an instance of AudioPathControl.
I found a LINK on how to do it on the Blackberry Knowledge base, but it only tells me how to do it using the Player class, which I don't want to do. Is there any way to get an instance of AudioPathControl of the current Application?
I would prefer to play a tone programmatically instead of including my own sound file. I found the following code snippet for that.
Player p = javax.microedition.media.Manager.createPlayer(javax.microedition.media.Manager.TONE_DEVICE_LOCATOR);
p.realize();
ToneControl tc = (ToneControl) p.getControl("ToneControl");
AudioPathControl apc = (AudioPathControl) p
.getControl("AudioPathControl");
apc.setAudioPath(AudioPathControl.AUDIO_PATH_HANDSFREE);
tc.setSequence(mySequence);
p.start();
But the problem is that apc is null and throws an Exception. Any solution?
Check the section Where Does the Sound Go? (preview from Google Books), from Advanced BlackBerry 6 Development By Chris King.

Categories