Android :: Determining Phone Looking At True North
May 11, 2010I 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 RepliesI 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 RepliesDoes anyone know if google maps can point in direction of movement top instead of always north. Not good when driving.
View 16 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(); } }
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 RelatedHow can I tell if a device is using HTC's SenseUI? I thought about using android.os.Build information, but they seem inconsistent. Is there a more definitive way? I need to be able to tell if I can launch the calendar by using com.android.calendar or com.htc.calendar.
View 1 Replies View RelatedMy question is- with the telephony manager, is there a way to determine what number the phone is off hook with? I thought getLine1Number() might return that phone number that is being dialed, but it is not what I expect. I am working with 2 emulators, and added a log line so that I could see what that method is doing. When dialing another emulator, I expected getLine1Number() to return 5554, but it was 15555218135. Perhaps there is another method I should be using instead? Do I need to be into the source code to get the information I want?
View 1 Replies View RelatedI was wondering if there is a way to determine who passed an intent to my application. For example, I have a service, that I want to act differently depending on who passed the intent (for security reasons). I'm trying to sandbox each calling application, so they only have access to their data stored in my application.
For it to be secure, I cannot trust any application to be truthful about the identifying data it is passing into my service. Therefore, I need some system way of identifying who sent the intent in a way that the calling application cannot change that information. I don't know if it is possible, but I can't find anything in the Intent class, and I was wondering if there may be another structure which does what I want it to. If it is not possible, I would like to get some type of mechanism to do this in the roadmap.
I'm using a UNIX socket to facilitate communication on and Android device between a system level daemon I've got running in C and an application I've got running in Java. I'm much more of a C coder than a Java coder, so I'm having some issues when trying to read in data from the socket on the Java side. Currently, my code is as follows:
try{//Prepare to write the command and read the ACK
InputStream is = receiver.getInputStream();
OutputStream os = receiver.getOutputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(is));..............................
How do you determine (programatically) if an Android device is: rooted Running a cracked copy of your software or rom. I have some sensitive information in my database, and I would like to encrypt it when the phone is rooted aka the user has access to the database. How do I detect that?
View 2 Replies View RelatedIs it possible to determine the unique bluetooth MAC address for an iPhone and an Android (and to a lesser extent, other smartphones) from within an app on said device? Is my assumption that the MAC address is universally unique correct? A general yes or no would be helpful. Example code in the case of an iPhone or an Android would be extremely helpful.
View 2 Replies View RelatedI have created multiple bitmaps - one for each folder (mdpi, hdpi, ldpi). Can someone show me some code or point me to the appropriate method that will allow me to detect which resource Android decided to load.
View 4 Replies View RelatedQuestion: How do you programmatically distinguish between directories and regular files in the assets folder?
When using AssetManager to access files in the assets folder, it seems impossible to determine if a file is in fact a file or a directory. You get the list of files from the list method and then open the file using the open method. I thought perhaps using the openFd method to get the asset file descriptor (and then subsequently requesting the normal file descriptor) would provide me some information. But requesting the file descriptor for a directory results in an IOException (which makes sense since what would it mean for a directory to have a file descriptor...?).
Currently I'm relying on that IOException (resulting from attemptng to open a directory in the assets folder) in order to determine if a file is in fact a directory. (Opening a regular file works just fine). This seems like a bad idea. Any other suggestions to distinguish between a file and a directory?
I am calling the ZXing scanner from Screen-A using intents. Once the scan is done control of course returns to the code behind Screen-A and I do some other work before calling Screen-B. Problem is the screen is black during this work period and I cannot determine the proper context to use to display a "working..." Toast/msgbox.
View 2 Replies View RelatedI'm working on an Android App where the user has different options for sorting the displayed data that comes from the database. Currently my orderBy string that I pass to Androids query() method looks like this:
"LOWER("+columnName+") ASC"
The problem with this is that if the data type in the column specified by columnName is integer, calling LOWER() on it will cause it to be sorted alphabetically, i.e. based only on the leftmost digit, which of course doesn't make any sense for numeric data. Hence I only want to apply LOWER() if the data type of the column is not integer. What I have in mind is a statement like this:
"CASE WHEN [data type of columnName is integer] THEN "+columnName+" ASC ELSE LOWER("+columName+") ASC END"
The part in the brackets is what I don't know how to do. Does SQLite provide a function to determine a column's data type?
I thought I'd share a script that I've been working on: http://www.anddev.org/viewtopic.php?p=30732
It lets you generate parameterizable histograms of Android Market sales by automatically downloading data from Google Checkout.
I am trying to implement a robust RSS/Atom reader for android, and since Xerces won't compile I am struggling to find an alternative. I am using org.xmlpull.v1.sax2.Driver(), however this just wraps a DOM parser with SAX callbacks. Is there anything comparable to Xerces on Android?
View 3 Replies View RelatedI got a mytouch 3g figuring it would handle voip like iphone and wm phones. But to my dismay, it appears there are no true VOIP apps for android that will allow me to call over wifi/3G from Germany.
I have read about sipdroid, truphone, skype lite, iscoot and others, but they all make a local call first, even to members of the same service -totally defeats the purpose. You'd be better off using a calling card!!
Anyway, just wondering if I am missing something. I got an android phone because I wanted to be part of something different, with great potential. I just didn't realize that it would be different in such a disadvantageous way...
I wish to have one application that runs in the background, which knows when any of the built-in applications (messaging, contacts, etc) is running. So my questions are: How I should run my application in the background. How my background application can know what the application currently running in the foreground is.
View 4 Replies View RelatedI have a tab widget i need to make it appear at the bottom of the screen, however i need to set the property android:layout_alignParentBottom="true", but this widget is created on code. How can i set this propety to True on code side (not on xml side)
View 2 Replies View RelatedI am trying to make an app that can work with or without the Google Maps API present. Eclipse gives me an error when trying to use android:option as an attribute (I have the latest SDK, I think, revision 6). Also, when I set the build target without the Google Maps library, I get an error from my class that extends MapActivity.
View 10 Replies View RelatedI have been looking around today and am trying to find a VoIP application that will actually work.
Let's say, what if I got my phone shut off from VZW, would there be a way to make VoIP calls over wifi? I have seen posts about using Google Voice in conjunction with other programs. Also, Nimbuzz? Anyone have a positive approach they have used for this?
I will be going out of the US for a while and will be getting my VZW account inactive for a while. I am looking for a way in which I'll be able to still use my Droid Incredible to make calls to the US using wifi. I'd even be willing to make calls just to Skype friends or Nimbuzz friends. I am hoping that someone else has found a way to accomplish this.
Cause it doesn't.I have a service running an Asynctask to do some work. I bind to it from an activity and call a cancel method. The service, in turn, calls AsyncTask.cancel(true);
AyncTask.cancel returns true. Nonetheless, the thread is still running happily and still doing the things in doInBackGround, sending notifications along the way.
There is no sign that it attempted to kill the thread. I am not using NDK calls or anything that I think should stop if from taking down the thread. What am I doing wrong? Or is this a known issue?
I added android:fastScrollEnabled="true" to the xml description of my listview class. I was (probably mistakenly) expecting this to magically transform the scrolling of my really huge listview so that the thumb button and the indexes display on the right side.
Is there more to hooking up the listview so that the framework knows what its alphabetizing? I have custom defined cells.
I am coming from Windows Mobile 6.5 and was using PocketShield as my lock screen replacement. One thing that I am looking for in an android app is..
1. The ability to enter pin or pattern from the lock screen app while also displaying all the new features of the app. One screen to rule them all.
2. I now use WidgetLocker and it works great except that I have to enter the pattern after sliding my app. What is the point? Either I enter the pattern before I select the app from the home screen or after when sliding. I thought I was able to use the app on the slicker "outside" of pattern security.
How can you programmatically set the android:singleLine="true" property of a TextView?
I want my EditText to open a numeric keypad with the "Done" button.
I've got a ListActivity using the Theme.Dialog theme and windowNoTitle set to true.
Unfortunately, when I do this, the header rows (just normal rows in the list but they look like sub headers) refuse to fill_parent width (instead, they wrap_content - the header text).
I noticed this was not a problem when using the Theme theme so I started narrowing everything down to what was causing the problem.
The answer: windowIsFloating. Theme.Dialog sets this to true, and if I override this to false, then the headers happily fill the parent width.
Is there a way around this (because I would like to set windowIsFloating to true)?
would like to add a zoom control to the map. I also want to layout the position of the zoom Control instead of the default middle bottom position. I can do this by getZoomControl but it is deprecated.
Could anyone tell me how to do this with setBuildtInZoomControls?
Before asking my doubt, let me clarify my understanding of allowTaskReparenting...
Suppose there exists a Task (say Task 1) and this task has an activity (say Activity 1) which wants to call my Activity (say Activity 2). Let my activity (activity 2) set the attribute allowTaskReparenting to true and let my activity have a specific taskAffinity(affinity1). When Activity1 calls my activity (activity2), my activity becomes part of the task1. But suppose another task (task2) is already present/created with the same taskAffinity as mine (affinity1) and an activity in that task (say activity3) tries to start my activity, my activity gets re- parented to task2.
Not sure if i was clear enough. If i were to rephrase my words...
If my activity has allowTaskReparenting set to true and an instance of my activity is already present in task1. If task2 with the same task affinity as my activity tries to start my activity, the EXISTING activity gets re-parented from task1 to task2.
My quesions:
(1) Is my understanding correct ?
(2) If I am correct then a single instance of my activity gets shifted from task1 to task2. So 2 activity objects of my activity are NOT created.
When using a mediaplayer to play back an audio file, you can set looping to true - that's not the issue here.
If looping is set to true, there's still an audible gap between the file finishing and then starting again.
How could I achieve true gapless playback? I've attempted using two instances of the same file, overriding oncomplete and onseek.. can't seem to improve the gap though.
I am trying to build AOSP for my Huawei U8836D, so I am making my own device tree. How do I determine which files in the stock ROM are proprietary, so I can define them in extract-files.sh?
View 1 Replies View Related