Android :: Compass Pointing Direction Other Than North

Sep 16, 2010

I'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(); } }

Android :: Compass Pointing Direction other than North


Android :: Finding Direction Using Compass Interface

Jan 11, 2010

I need to know if there is an interface to access the direction in which the phone is pointing.

View 2 Replies View Related

Android :: Camera Application With Compass Direction Overlay?

Jul 12, 2010

I'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.)

View 5 Replies View Related

Android :: Determining Phone Looking At True North

May 11, 2010

I looked over SensorManager and was still unsure, how do I detect if the phone is looking at true north (or any other direction for that matter).

View 1 Replies View Related

Android :: Google Maps Always Point North?

Oct 27, 2008

Does anyone know if google maps can point in direction of movement top instead of always north. Not good when driving.

View 16 Replies View Related

Android :: How To Get Location Ball / Arrow To Face Upward / North?

Aug 1, 2010

My question is, in car dock mode/ my location it has me traveling south or downward, how can I Get the my location ball or arrow to face upward or north?

View 2 Replies View Related

Android :: FileNotFoundException When Pointing To Ebay.com From Mobile

Sep 7, 2010

If I pass http://www.ebay.com to this. Somewhere along the way ebay changes my url, perhaps a redirect. What's weird is Android java can't open the page. u = new URL(txturl.getText().toString());

I get the error below as it apparently opening the new mobile site. I'm just wonder at what point my url changes and If I somehow stop this. It does not appear to happen if I point to yahoo, google, amazon or other major sites. I just noticed this in my testing.

CODE:......................

View 1 Replies View Related

Android :: Changing Image Of Button On Pointing Mouse Over It

Sep 8, 2010

In the emulator on touching my button I want its image to be changed. I just want to bring my mouse pointer there, without click. This can be observed for other keys of the emulator. On touch a blue image appears on the keys.

View 2 Replies View Related

Android : How To Add Entry (pointing To Activity) To "Home Screen?

Sep 20, 2009

I'm writing program for Android (SDK 1.5). I would like to know how to add/register one of my program activities in "Home Screen -> Menu -> Add-> Shortcuts" (or on Hero "Home Screen -> Menu -> Add to Home-> Shortcut") so that user will be able to add it to his home screen. Is there an Intent Filter or any other way to achieve that?

View 2 Replies View Related

Android : Compile / Running Tests By Pointing A Standard JUnit?

Aug 18, 2010

It appears that Android supports JUnit 3 out of the box.�However, I have some pre-existing JUnit 4 unit tests that I'd like to try on Android. I've tried adding the JUnit 4 jar to eclipse and compiling/ running the tests by pointing a standard JUnit run against them, but nothing seems to happen.�There's no evidence in the eclipse console or the Android emulator that any tests have been run.

Can anyone with knowledge about this subject comment?�Is it even possible to run JUnit 4 tests under Android, and if so, is there a step-by-step explanation as to how to achieve this (preferably under Jetbrains IDEA IDE, and/or Eclipse).

View 11 Replies View Related

Android :: Add Entry - Pointing To Activity - To Home Screen - Menu - Add - Shortcuts?

Sep 20, 2009

I'm writing program for Android (SDK 1.5). I would like to know how to add/register one of my program activities in "Home Screen -> Menu -> Add-> Shortcuts" (or on Hero "Home Screen -> Menu -> Add to Home-> Shortcut") so that user will be able to add it to his home screen. Is there an Intent Filter or any other way to achieve that?

View 2 Replies View Related

Motorola Droid :: Threads About Unlock Sliders Pointing Up And Down?

Feb 10, 2010

Instead of left and right? I believe there were screenshots.

If anyone remembers or subscribed to (or posted on) these threads and can find them, let me know please. I can't seem to find them.

View 6 Replies View Related

Android : How I Can Get Direction In Htc Desire

Nov 28, 2010

Every one can any body explain to me how I can get direction in Htc desire ,cause when I ask about any direction or end point always the answer is no route.

View 6 Replies View Related

Android :: Accelerometer Direction Of Shake?

Apr 8, 2010

I've been playing with the data given by the accelerometer,trying to work out how I can gauge a shake from front to back or side to side. This all seems straightforward enough.But I'd love to know the direction of the shake. So, if the user is shaking backwards and forwards, I want to know if the device is moving away from the user, or back towards him/her. I can't find any way of telling this.

View 6 Replies View Related

Android :: Direction Information In MapView

Aug 16, 2010

I want to show the direction information in my app.Direction from one address to the another using Google maps and also wanted to set overlays at the starting address and the destination address.Is there any classes in android too do that.

View 5 Replies View Related

Android :: Draw The Direction Arrow On The Map

Sep 13, 2010

I am creating a class extending mylocationoverlay. then, i override the draw method. is this the correct method? because after i rewrote the draw method, the map tile cannot render.

View 4 Replies View Related

Android :: Scrolling The Wrong Direction?

Dec 7, 2009

Scrolling on an Android phone makes sense because it's like you're physically sliding the page upwards. However, now that I'm used to doing that, when I get on my laptop and start to scroll with my touchpad, sometimes I find myself scrolling the wrong direction. On a touchpad you drag downwards to go down on the page, or to slide the page upwards. So it's backwards from the motion you would make on your phone.

View 17 Replies View Related

Android :: Calculating Direction From Point A To B

Sep 17, 2010

I'm trying to create a compass for my application BUT the difference is that, instead of having a line always pointing to north, I want this line to point for a specific point. I've been trying dozens of algorithms and nothing works. I've finally found one that points me exactlly to the point I want. But it doesn't move if I change the position of the device which is my objective. Basically, what I want is that no matter the direction I'm using my device. The line always point me to the point (picLatitude,picLongitude). I understood that for the line to move, I can't use static variables. I need to use the values offered by the onSensorChanged(SensorEvent event). This are the data I have available:

event.values[0]: azimuth, rotation around the Z axis (device in relation to north, 0º) event.values[1]: pitch, rotation around the X axis event.values[2]: roll, rotation around the Y axis mLatitude: device current latitude got from GPS (variable) mLongitude: device current longitude got from GPS (variable) picLatitude: static picture latitude established previously picLongitude: static picture longitude established previously distance: distance in Km from device to the picture calculated previously

And this the formula that works correct, and gives me the correct angle. (But it doesn't use any of the Sensor Data so the line Compass doesn't move):
double dLong = picLongitude - mLongitude; double y = (Math.sin(dLong) *
Math.cos(picLatitude)); double x = (Math.cos(mLatitude) * Math.sin(picLatitude) - Math.sin(mLatitude)*Math.cos(picLatitude)*Math.cos(dLong)); double angleDegreesWrongRange = Math.abs(Math.toDegrees(Math.atan2(y, x))); float angleDegrees = (float) ((angleDegreesWrongRange+360) % 360);
myCompass.updateDirection(angleDegrees);
I got this "bearing" formula from this website: http://www.movable-type.co.uk/scripts/latlong.html. I've try adding, subtracting, the azimuth.. I've tried with the others, seriously at this point I'm just demoralized.

View 13 Replies View Related

Android :: Scrolling Direction And Velocity

Jul 8, 2010

Is there an easy to know the direction of scroll (up or down for a vertical list) and the scroll velocity for ListView's?

View 2 Replies View Related

Android :: Way To Get Direction Between Two Locations In Droid?

Aug 2, 2010

Is there any way to find the direction between two locations in Android?

View 3 Replies View Related

Media :: Detect Voice Direction On Android

Nov 3, 2010

I am wondering whether it is possible to detect voice direction in android or not? For example on nexus one using the actual mic and the noise cancellation mic or using any other method?

View 4 Replies View Related

Android :: Sub Activity Flies In Horizontal Direction?

Nov 18, 2009

My current app flies in a sub activity when you flick-up. Problem is, it flies in horizontally from the right. I want it to fly in vertically from the bottom to match the flick direction. I'm sure this must be an xml property somewhere, but I can't find it. Does someone have a pointer as to how to set this?

View 10 Replies View Related

Android :: Change Direction Of Playback Video?

Jun 1, 2009

I am using Tablet skin for running emulator output. All the menu and list items are displayed properly e.g. Horizontally whereas Videos are being played vertically. How can I change the direction of video? Kindly reply as soon as possible.

View 2 Replies View Related

Android :: How To Play Video In Time Reversed Direction?

Oct 12, 2009

How to play video in a time reversed direction? The requirement is to loop playing forward and backward repeatedly.

View 7 Replies View Related

Android :: Show The Direction On Screen That Phone Is Facing

Sep 22, 2010

I want to show the direction on the screen that phone is facing.

For example:

0
|- []
|_
South --- North

In the above diagram the phone would display "North". Since the user (the stick with 0 for his head) is holding out the phone (the [] in the diagram) pointing north.

I found this example. I understand what it's doing except it seems to calculate yaw, pitch, roll, and inclination. What are those and how would I use them to simply find which way the phone is pointing?

Also this android documentation mentions X, Y, and Z axises but I don't see anywhere that says how those axises correspond to the phone? Is Z going from the bottom of the phone to the top?

View 1 Replies View Related

Android :: Touch Mode Catch Scrolling Direction

Oct 20, 2010

I want to ask that is that possible do in android catch the in the touch mode catch the scrolling direction ? When user touch on the screen left to right, can I catch the change ?
If it is possible which listener can ı use ?

I found some of the methods and listeners but I 'm not sure that therse are represent my requirement .
http://developer.android.com/reference/android/text/method/Touch.html

Public Methods
static int getInitialScrollX(TextView widget, Spannable buffer)
static int getInitialScrollY(TextView widget, Spannable buffer)

View 2 Replies View Related

Android :: Change Direction (up Or Down) Of An AutocompleteTextview Drop Down List?

Nov 15, 2010

I would like to know how I can change the direction (up or down) of an AutocompleteTextview drop down list.

View 2 Replies View Related

Android : Driving Direction Info From Maps Application

Mar 31, 2009

After launching Android maps application from other application, how to get driving direction info from maps application? e.g. distance, estimated driving time, etc.

View 6 Replies View Related

General :: Arrow / Direction Keys For Android 3.2 Smartphones

Feb 21, 2012

Does Android 3.2 smartphones all support arrow/direction keys? If so, what are the keyCode for the four keys?

does KeyEvent class already defined these keys?

View 2 Replies View Related

Android :: Touch Mode Catch Scrolling Direction / Left To Right

Oct 20, 2010

I want to ask that is that possible do in android catch the in the touch mode catch the scrolling direction ? When user touch on the screen left to right, can I catch the change ? If it is possible which listener can ı use ?

I found some of the methods and listeners but I 'm not sure that therse are represent my requirement . http://developer.android.com/reference/android/text/method/Touch.html

Public Methods static int getInitialScrollX(TextView widget, Spannable buffer) static int getInitialScrollY(TextView widget, Spannable buffer)

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved