Hi Forum,
I've been trying to write an piece of code in Android mode in Processing to my HTC Desire's bluetooth to communicate with Arduino. I am using Processing 1.5 / Android 2.1 (API Level 7)
I have tried using the
Amarino library and also had a little play with the
SweetBT library but when trying to compile I get the following error:
[javac] /Applications/android-sdk-mac_x86/tools/ant/main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 2 source files to /var/folders/Vk/VkXxMDamHUytWiiZWvQkgE+++TI/-Tmp-/android3489911194530507138.pde/bin/classes
[javac] /var/folders/Vk/VkXxMDamHUytWiiZWvQkgE+++TI/-Tmp-/android3489911194530507138.pde/src/processing/android/test/stickydatav0b2/stickydatav0b2.java:154: cannot access at.abraxas.amarino.Amarino
[javac] bad class file: /var/folders/Vk/VkXxMDamHUytWiiZWvQkgE+++TI/-Tmp-/android3489911194530507138.pde/libs/AmarinoLibraryv055.jar(at/abraxas/amarino/Amarino.class)
[javac] class file has wrong version 50.0, should be 49.0
[javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
[javac] Amarino.disconnect(this,EXTRA_DEVICE_ADDRESS);
[javac] ^
[javac] 1 error
BUILD FAILED
/Applications/android-sdk-mac_x86/tools/ant/main_rules.xml:384: Compile failed; see the compiler error output for details.
Total time: 1 second
Here is the code, I am trying to compile:
- import android.app.Activity;
import android.content.SharedPreferences;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.location.LocationListener;
import android.location.GpsStatus.Listener;
import android.location.GpsStatus.NmeaListener; // not needed yet, but going for nmea data next!
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import at.abraxas.amarino.*;
import at.abraxas.amarino.plugin.*;
import java.util.List;
String EXTRA_DEVICE_ADDRESS = "00:06:66:42:89:F6";
String[] fontList;
PFont androidFont;
LocationManager locationManager;
MyLocationListener locationListener;
double currentLatitude = 0;
double currentLongitude = 0;
float currentAccuracy = 0;
String currentProvider = "";
// Define a listener that responds to location updates
class MyLocationListener implements LocationListener {
void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
currentLatitude = (double)location.getLatitude();
currentLongitude = (double)location.getLongitude();
currentAccuracy = (float)location.getAccuracy();
currentProvider = location.getProvider();
}
void onProviderDisabled (String provider) {
currentProvider = "";
}
void onProviderEnabled (String provider) {
currentProvider = provider;
}
void onStatusChanged (String provider, int status, Bundle extras) {
// Nothing yet...
}
}
void onResume() {
super.onResume();
// Build Listener
locationListener = new MyLocationListener();
// Acquire a reference to the system Location Manager
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
}
void onPause()
{
super.onPause();
}
void onDestroy()
{
super.onDestroy();
Amarino.disconnect(this,EXTRA_DEVICE_ADDRESS);
}
//-----------------------------------------------------------------------------------------
TwitterFactory tf;
String ConsumerKey = "*******";
String ConsumerSecret = "*******";
String oauth_token = "*******";
String oauth_token_secret = "*******";
void setup() {
size(screenWidth, screenHeight);
background(0);
fontList = PFont.list();
androidFont = createFont(fontList[4],35,true);
textFont(androidFont);
smooth();
ConfigurationBuilder cb = new ConfigurationBuilder(); //ConfigurationBuilder declared cb is a new instance of this
cb.setDebugEnabled(true)
.setOAuthConsumerKey(ConsumerKey) //sets the Consumer Key String
.setOAuthConsumerSecret(ConsumerSecret) //sets the Consumer Secret String
.setOAuthAccessToken(oauth_token)
.setOAuthAccessTokenSecret(oauth_token_secret);
tf = new TwitterFactory(cb.build());
}
//-----------------------------------------------------------------------------------------
double latitude;
double longitude;
float res;
String resUnit;
int myrpp;
void draw() {
background(0);
text("Latitude: "+currentLatitude, 20, 40);
text("Longitude: "+currentLongitude, 20, 75);
text("Accuracy: "+currentAccuracy, 20, 110);
text("Provider: "+currentProvider, 20, 145);
Twitter twitter = tf.getInstance(); //Build new instance of Twitter
latitude = currentLatitude; //lat is the same as phone position
longitude = currentLongitude; //lon is the same as phone position
res = 0.09; //Search within a resolution of " "
resUnit = "km"; //Chose the unit to measure km or mi
myrpp = 1000; //Results per page
if (currentProvider != "")
{
try {
QueryResult result = twitter.search(new Query().geoCode(new GeoLocation(latitude,longitude),res,resUnit).rpp(myrpp));
List <Tweet> tweets = result.getTweets();
text("Tweet Count: "+tweets.size(),20,180); //Write the Tweet Count
ellipseMode(CENTER);
ellipse(screenWidth/2,screenHeight/2,tweets.size()*6,tweets.size()*6);
for (int i=0; i <tweets.size(); i++)
{
Tweet tweet = (Tweet)tweets.get(i);
long ID = tweet.getId();
}
//exit();
}
catch (TwitterException te) {
te.printStackTrace();
text("Failed to search tweets: " + te.getMessage());
//exit();
}
}
}
Has anyone had any success with Amarino or SweetBT compiling to Android? Can anyone help?
Thanks
Mat