Is it possible to create an application with Mono for Android and control Arduino without using Eclipse but using Visual Studio and C#?
I checked some examples but everyone uses Java and Eclipse.
Simply put, the answer is yes, it is possible. The real question is: How? I'm going to assume you've already written you first Android app with Mono.
Next, you need to decide how you will connect your Android device to the Arduino. Bluetooth? Wi-Fi? Web?
Next, it's simply a matter of using the appropriate Android API. Check out the Xamarin documentation for Android.
Update
Much more than what I present below is available with the ported MonoDroid sample applications. Specifically, you would be interested in the BluetoothChat example.
Make sure you also take a look at adding permissions to the manifest file, and of course, the Android Developer Guide for Bluetooth.
That said, here's a tiny something to get you started, based on Android Quick Look: BluetoothAdapter:
txtStatus.Text = "Getting Bluetooth adapter...";
BluetoothAdapter bluetooth = BluetoothAdapter.DefaultAdapter;
if( bluetooth == null )
{
txtStatus.Text = "No Bluetooth adapter found.";
return;
}
txtStatus.Text = "Checking Bluetooth status...";
if (!bluetooth.IsEnabled )
{
Toast.MakeText(this, "Bluetooth not enabled. Enabling...",
ToastLength.Short).Show();
bluetooth.Enable();
}
if (bluetooth.State == State.On)
{
txtStatus.Text =
"State: " + bluetooth.State + System.Environment.NewLine +
"Address: " + bluetooth.Address + System.Environment.NewLine +
"Name: " + bluetooth.Name + System.Environment.NewLine;
}
else
{
txtStatus.Text = "State: " + bluetooth.State;
}
Related
I have used com.gluonhq.charm.down.plugins.StorageService to look for how much it would be possible to store with a application on windows, mac, iOS and Android seperate devices. I get a strange result on iOS (the rest is as you can expect with windows, mac and Android) - and need help to understand why that is.
According to the StorageSevice I have 5363227164672 (bytes) on my iPhone 6. How is that possible/why such strange result? That is 5365 GB!
File privateStorage = null;
try {
privateStorage = Services.get(StorageService.class).flatMap(StorageService::getPrivateStorage).orElseThrow(() -> new FileNotFoundException("Could not access prrivate storage"));
} catch (FileNotFoundException ex) {
Logger.getLogger(Go.class.getName()).log(Level.SEVERE, null, ex);
}
// a simple print to javafx textArea method:
out("size is " + privateStorage.getFreeSpace());
Here is the documentation for StorageService.
Edit:
With .getUsableSpace() I get 179GB on iPhone6 which is not correct. Using .getUsableSpace() on windows gave the same result as before, (Android and Mac not rechecked with getUsableSpace().
I am writing my first ever mobile app for IOS using Xamarin and i need to use the camera to scan a product barcode similar to the function of many shopping apps. Would any of you lovely people know how i go about this or if there are any plug-ins for this?
Thanks
Steve
For the most part, I have found ZXing Mobile to be the best option as far as reading barcodes is concerned.
The syntax is very .NET friendly:
buttonScan.Click += (sender, e) => {
var scanner = new ZXing.Mobile.MobileBarcodeScanner();
var result = await scanner.Scan();
if (result != null)
Console.WriteLine("Scanned Barcode: " + result.Text);
};
Source and more info: https://components.xamarin.com/view/zxing.net.mobile
I've developed an app using Cordova and the Web Audio API, that allows the user to plug in headphones, press the phone against their heart, and hear their own heartbeat.
It does this by using audio filter nodes.
//Setup userMedia
context = new (window.AudioContext||window.webkitAudioContext);
navigator.getUserMedia = (navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
navigator.getUserMedia(
{audio:true},
userMediaSuccess,
function(e) {
alert("error2 " + e.message);
});
function userMediaSuccess(stream)
{
//set microphone as input
input = context.createMediaStreamSource(stream);
//amplify the incoming sounds
volume = context.createGain();
volume.gain.value = 10;
//filter out sounds below 25Hz
lowPass = context.createBiquadFilter();
lowPass.type = 'lowpass';
lowPass.frequency.value = 25;
//filter out sounds above 425Hz
highPass = context.createBiquadFilter();
highPass.type = 'highpass';
highPass.frequency.value = 425;
//apply the filters and amplification to microphone input
input.connect(lowPass);
input.connect(highPass);
input.connect(volume);
//send the result of these filters to the phones speakers
highPass.connect(context.destination);
lowPass.connect(context.destination);
volume.connect(context.destination);
}
It runs fine when I deploy to Android, but it seems most of these features aren't available on iOS mobile browsers.
I managed to make getUserMedia function using the iosRTC plugin, but createMediaStreamSource is still "not a function."
So, I'm looking for an alternative to the Web Audio API that can filter out frequencies, or if there are any plugins I could use, that would be perfect.
There's no way to do this on ios web. You'd need a native app, since Apple doesn't support audio input in safari.
Did you try to use
document.addEventListener('deviceready', function () {
// Just for iOS devices.
if (window.device.platform === 'iOS') {
cordova.plugins.iosrtc.registerGlobals();
}
});
You asked this question quite a while ago, but sadly createMediaStreamSource is still not supported in Safari Mobile (will it ever be?).
As previously said, a plugin is the only way to achieve this, and there is actually a Cordova/Phonegap plugin that does exactly that. cordova-plugin-audioinput gives you access to the sound from the microphone using either the Web Audio API or by callbacks that delivers raw audio data chunks, and it supports iOS as well as Android.
Since I don't want to post the same answer twice, I'll instead point you to the following answer here on stackoverflow, where you'll also find a code example: https://stackoverflow.com/a/38464815/6609803
I'm the creator of the plugin and any feedback is appreciated.
Good news, full support for ios safari
https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createMediaStreamSource
I'm trying to implement speech recognition on Chrome on the iPad without any luck. Just to cut to the chase and remove any dependencies on my implementation of the webkitSpeechRecognition api, Glenn Shire's excellent sample code does not run on Chrome v27 on an iPad 1 running iOS 5.1.1 or Chrome v31 on an iPad3 running iOS 7.0.4, at least as far as I can tell. It fails at this line:
if (!('webkitSpeechRecognition' in window)) {
r.onState('upgrade');
return;
}
I can't figure out a workaround, and I've not seen any online postings that say anything about speech recognition not working in the iOS version of Chrome. Anyone else run into this?
Chrome on iOS doesn't support Speech Recognition at the moment.
Google have to use iOS UIWebView that mean there is no special web interpretation feature that are not supported on Safari.
You may have a look to this link.
In case you want to recognize few simple commands you can look on Pocketsphinx.js
The code to recognize speech is simple:
var id = 0;
recognizer.postMessage({command: 'initialize', callbackId: id});
var keyphrase = "HELLO WORLD";
recognizer.postMessage({command: 'addKeyword', data: keyphrase, callbackId: id});
recognizer.postMessage({command: 'start', data: id});
recognizer.postMessage({command: 'process', data: array});
recognizer.postMessage({command: 'stop'});
recognizer.onmessage = function(e) {
if (e.data.hasOwnProperty('hyp')) {
alert(e.data.hyp);
}
};
For more details see also the full example here
I started in blackberry development.
Currently, I try to develop App with:
Blackberry Widget API (Javascript + CSS) and Eclipse (JAVA)
1/
When I try with Blackberry Widget API, I try to load a webservice in .NET, I try to run this in simulator 8520 curve... and the connect to the webservice not works, I use the config.xml to set the domains but nothing happends, later I test in 9800 simulator and works fine... but I have some fear because this app is for run in any device :(
2/
When I try with Eclipse and kSOAP2 Library,
This is my code:
String WSD_URL = "http://service.com/service.asmx";
String WSD_NAMESPACE = "http://service.com/GetInfo";
String WSD_ACTION = "http://service.com/GetInfo/fGetInfo";
SoapObject soap = new SoapObject(WSD_NAMESPACE, "fGetInfo");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.bodyOut = soap;
envelope.encodingStyle = SoapEnvelope.XSD;
HttpTransport ht = new HttpTransport(WSD_URL);
try {
ht.call(WSD_ACTION, envelope);
} catch (Exception e){
}
When I launch the app in simulator... nothing happend, few minutos after I see a error in the white screen with message "controlled access exception" :(
I have doubt here because I dont know how to solve this and if this app run in any devive.
In eclipse I see JRE 6.0
To access dot net webservice, instead of Ksoap method, try this one.. http://whatpaulhaslearnt.wordpress.com/2011/04/19/consuming-a-net-web-service-from-a-blackberry-native-application-using-the-java-me-platform-sdk-3/ .. this is the best way of accessing dot net webservice..