Android :: Compass Still Crashing
Aug 12, 2009I've modified the code a bit since the last time, and now it crashes at runtime. I've got the log-cat and code below. how to go about debugging.
CODE:..................
I've modified the code a bit since the last time, and now it crashes at runtime. I've got the log-cat and code below. how to go about debugging.
CODE:..................
I have the HTC hero right now with the Android 1.5 and was wondering if there is a compass app that i can download which is similar to the iPhone 3GS?
View 4 Replies View RelatedI'm trying to make a map with showing my location with an arrow that point to the way we are facing. the arraw image is something like this:
^ 0
Always pointing north, so i rotate it with sensor orientation event ( image.rotate(values[0]) )
I would like to ask if google map's north is always on 12 o'clock? because i try sometimes the arrow point to wrong direction. how to accurately make this thing works?
I have a marker on the map using an Overlay. I also have access to the compass sensor which I'm able to show a textView with the orientation values (0 to 359). How can I apply this values to the marker? (which is a drawable). I already have a MAtrix created but when I insert the orientation value gives me an error, here it is:
GeoPoint geopoint = new GeoPoint((int) (newLocation.getLatitude() * 1E6),
(int) (newLocation.getLongitude() * 1E6)); Paint paint = new Paint();
Point pt = new Point(); mapView.getProjection().toPixels(geopoint, pt);
Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.user2);
Matrix matrix = new Matrix(); matrix.postTranslate(-25, -25);
matrix.postRotate(direction); matrix.postTranslate(pt.x, pt.y);
paint.setAntiAlias(true); paint.setFilterBitmap(true);
int width = bmp.getWidth(); int height = bmp.getHeight();
Bitmap changedBitmap = Bitmap.createBitmap(bmp, 0, 0, width, height, matrix, true);
BitmapDrawable icon = new BitmapDrawable(changedBitmap);
icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
userOverlay useroverlay = new userOverlay(icon); useroverlay.addItem(item);
mapView.getOverlays().add(useroverlay);
I used the value retrieved from the sensor on "direction" but it doesn't work.
Am researching a problem with compass and sensor values returned by the phone. I found this thread: http://groups.google.com/group/android-developers/browse_thread/threa. Which seems related, but it's old so I'm starting a new one. I'm getting stuck values from both the compass and orientation sensors. It was fine yesterday, but today, I'm only getting values in a limited range (e.g. compass headings from 240 - 290), no matter how I orient the device. What's even more odd is that the radians returned from the call to Sensor Manager.get Orientation(), which returns radians, is giving consistently out of range values. Anyone see this same behavior, and if so, any fixes? Here's some sample sensor data. Format is heading, pitch, roll. The first set contains raw values, the second set contains values after I've applied the orientation matrix generated by the Sensor Manager. The third set contains values after I've smoothed the data with my own algorithm.
View 4 Replies View RelatedI want to test a compass app on the emulator. Is this possible or do i have to use a real device. Also I do not want to use gps.
View 2 Replies View RelatedI just installed google sky map and started it up all excited and I just don't get it. I have searched this forum and done google searches and no-one seems to have my issue so I think its something I am not getting but I cant see what it is. I fire up the app and it looks good.. but... the map on the screen goes in the opposite direction. As I rotate left the stars on the screen move left and as I rotate right the move right. up and down movements are fine.
When I point north or south it is correct but as I rotate the horizon says east when I point it west and west when I point it east.? I have recalibrated my compass.. When I run the compass app it works correctly.. even google maps in street view works correctly. It is only google sky map that seems to have reversed east and west. Has anyone else seen this? Is it just me being dumb?
I want to create a non-generic compass that uses rotating directions instead of a rotating needle as in the conventional compass. The drawing is like the illustration below..................
View 14 Replies View RelatedHow can I implement the Compass function having 2 geopoints (start and destination)?
View 10 Replies View RelatedI can't find much information out there on Android's hardware compass. I keep trying to setup my criteria to force Android to use the hardware compass. Basically my problem is I want the bearing to update even while the device is stationary. From my understanding the GPS will only update your bearing when your moving. I'd like bearing to update regardless if your moving or not. I've tried tricking the device in to thinking it's moving by setting the speed at a constant 10 but the bearing returns 0.0 always. My device for testing (currently) is a HTC tattoo. It has a compass so that's not the problem. So my question is, is there a way to get the bearing to update using hardware compass or not? regardless if your moving or not?
View 1 Replies View RelatedI need to know if there is an interface to access the direction in which the phone is pointing.
View 2 Replies View RelatedI'm trying to implement something that I don't even know if it's possible. So I have this class which implements a SensorEventListener like this:
private SensorEventListener mySensorEventListener = new SensorEventListener(){
@Override public void onAccuracyChanged(Sensor sensor, int accuracy) {
} @Override public void onSensorChanged(SensorEvent event) {
myCompass.updateDirection((float)event.values[0]); } };
And a class that handles the way the compass looks like this:
public static class compassLook extends View {
private Paint paintPointer = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint paintCircle = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint paintLeters = new Paint(Paint.ANTI_ALIAS_FLAG);
private boolean firstDraw; private float direction = 0 ;
public compassLook(Context context) { super(context); init();
} public compassLook(Context context, AttributeSet attrs) { super(context, attrs); init();
} public compassLook(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); init(); } private void init(){
paintPointer.setStyle(Paint.Style.STROKE); paintPointer.setStrokeWidth(3);
paintPointer.setColor(Color.argb(255, 209, 114, 2)); paintCircle.setStyle(Paint.Style.STROKE);
paintCircle.setStrokeWidth(2); paintCircle.setColor(Color.argb(150, 255, 255, 255));
paintLeters.setStyle(Paint.Style.STROKE); paintLeters.setStrokeWidth(1);
paintLeters.setColor(Color.argb(230, 255, 255, 255)); paintLeters.setTextSize(12);
firstDraw = true; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec),
MeasureSpec.getSize(heightMeasureSpec)); } @Override protected void onDraw(Canvas canvas) {
int cxCompass = (getMeasuredWidth()/2); int cyCompass = (getMeasuredHeight()/2);
float radiusCompass; if(cxCompass > cyCompass){ radiusCompass = (float) (cyCompass * 0.9);
} else{ radiusCompass = (float) (cxCompass * 0.9);}
canvas.drawCircle(cxCompass-50, cyCompass, radiusCompass, paintCircle);
if(!firstDraw){ // Desenho da linha que aponta canvas.drawLine(cxCompass-50, cyCompass,
(float)(cxCompass-50 + radiusCompass * Math.sin((double)(- direction) * 3.14/180)),
(float)(cyCompass - radiusCompass * Math.cos((double)(-direction) * 3.14/180)),
paintPointer); double mLatitude = (mLocation.getLatitude() / 1E6);
// I get this value from a LM request double mLongitude = (mLocation.getLongitude() / 1E6);
// I get this value from a LM request double picLatitude= Double.parseDouble(picLatitudeString);
// I get this value from a bundle double picLongitude = Double.parseDouble(picLongitudeString);
// I get this value from a bundle float direction = (float)
Math.toDegrees(Math.atan2(picLongitude- mLongitude, picLatitude-mLatitude));
float distancia = (float) (Math.sqrt(Math.pow(mLatitude- picLatitude,
2) + Math.pow(mLongitude-picLongitude,2)))/2;
//Desenho do texto que indica a distancia
canvas.drawText(String.valueOf(distancia) + "Km", cxCompass-30,
cyCompass+20, paintLeters); } } public void updateDirection(float dir)
{ firstDraw = false; direction = dir; invalidate(); } }
I need to build compass for my application.
From reading the documentation it seems there are two reasonable ways of doing this:
Sensor.TYPE_ORIENTATION method: This is the easy way of doing it. The problem with this is it is not accurate. When I compare my reading with Snaptic Compass it is about 10-15 degress off which for my purposes is unacceptable.
Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_MAGNETIC_FIELD and getRotationMatrix() in conjunction with remapCoordinateSystem() and getOrientation() method: The documentation says this "is usually more accurate". The problem is regardless of the delay I register with listener the compass goes crazy even when the device is stationary on flat surface.
I am now beginning an app which will use the compass and tilt sensors to determine a persons heading and line of sight. Can I assume the sensors on devices such as the G1 are fairly accurate or can I expect to run into problems such as the compass being 5-10 degress off etc?
View 4 Replies View RelatedI just read the developer blog post about non-phone Android devices such as tablets and GoogleTV - http://android-developers.blogspot.com/2010/09/brace-for-future.html.
I'm writing an accelerometer-based game and would like to filter for devices that have an accelerometer (or orientation sensor). Is there a way to do that? It would also be useful to filter for devices with a compass or GPS receiver.
I've noticed that I get a slightly different reading from the compass depending on how I hold the phone. If I hold it vertically, its different than when I hold it horizontal (ie parallel to a table or floor). Does anyone know the most accurate way to hold the phone for the compass?
View 5 Replies View RelatedI cannot find any tutorial on the web. How can I do it in a simple way?
View 1 Replies View RelatedNow that SENSOR_ORIENTATION is deprecated, what's the best practice for obtaining compass reading? The old way was so simple.
View 1 Replies View RelatedI have seen applications like gpsstatus which have compass and determines whether the device is heading north south etc. How can i determine the heading of my device?
View 1 Replies View RelatedI was just curious as to whether theres an application for a compass for the HTC Hero, similar to the one on the iPhone?
View 1 Replies View RelatedSuper compass is a compass in the English tools. There are many styles and backgrounds to choose from, the essential software for your trip.
Super compass, both app and home screen widget, several styles and backgrounds to choose.
Version 1.4:
- show GPS location
- show current address
- GPS status
- connectivity status
Feature
- Home screen widget
- change background
- change style
- calibrate
- GPS location, address
I want to use my image to replace the Compass image of MyLocationOverlay, how can i implement?
View 1 Replies View RelatedI'm a bit new to Android but after searching on the Market, the web and this forum, I can't seem to find anything like this but I feel like it has to exist (or hopefully will soon). I'm looking for a camera application that can place the current compass direction on the image (and stamp the saved image with the direction). The tilt of the phone would be cool to have, too, but just the compass would be great. I did find an application that shows the compass direction on over top of a feed from the camera ("Reality + Compass" by Udell Enterprises).
I want something just like this, but with the ability to save the image. In case you're wondering, I'd like to use this for bettering the storm spotting community. A problem when people send in images of clouds/storms/tornadoes/etc is that you never know (1) where the picture was taken and (2) in what direction. Ideally GPS location could be added, too, but for now I just want the compass. (Other image services can handle the location part fine, like Twitter for Android/Twitpic.)
(I'm on the HTC Aria, but I can sideload apps now thanks to the new version of HTC Sync.)
My compass and any apps that use it are all off. I've tried calibrating it through the compass app, but it's still real jumpy.
View 2 Replies View RelatedI am using these three lines to add a compass on the MapView: mMyLocationOverlay = new MyLocationOverlay (this,mapView);mMyLocationOverlay. enableCompass(); mapView.getOverlays() .add(mMyLocation Overlay) ; However the default position of the compass showing on the screen is not too good for my apps, and I want to move it to somewhere else. Anyone knows how I can achieve that?
View 2 Replies View RelatedI tried to find compass app in my htc legend, but no success. Seems that I have to look for one. But i don't know which one will work for my phone.
View 1 Replies View Relatedmy wife wants a compass app on her phone (I think this is so she knows which way to walk to the most expensive shops, and becuase her friends with iPhones have them ).... as it appears that there is not one on the SGS, can anyone reccommend the best one to download? I presume that they are all as accurate as each other, but are there any that have any nice additional features?
View 8 Replies View Relatedis there an app that makes use of the digital compass? also whats a good facebook app?
View 11 Replies View RelatedI am on T-Mob with my Desire and have just realised i have no Digital Compass.Or am i looking in wrong place ? ,have tried manage apps ,and its not listed ,compass mode works ok in Maps,so whats happening?.
View 10 Replies View RelatedI noticed that when I am lookinh at google map (satellite or normal), when I turn the phone the map will not stay to point to the same direction. It turns with the phone. Is this the way it should be?
I also downloaded the Compass application. and it behaves kind of wierd: holding the phone horizonally, I turn around. The compass should keep pointing to the north regardless how I turn. Mine is all over the place. If I point the phone to NE, it does show the N direction but when I try to turn the phone to point to the North it goes all over the place.
This is regardless GPS on or off. I am still at 1.5...