Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8162367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:41:29+00:00 2026-06-06T18:41:29+00:00

Is there an Android equivalent of didUpdateHeading (from iOS) ? Any sample code to

  • 0

Is there an Android equivalent of didUpdateHeading (from iOS) ? Any sample code to rotate the mapview using it?

Searched a lot, but couldn’t get a helpful hint.

Thanks in advance.

Edit: Let me expalain my question: In IOS, when the device changes its Heading, delegate object gets a call on its method: “didUpdateHeading”. In Android I could find “onLocationChanged” to get the coordinates, but no Heading information. How do I get the heading information in Android?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:41:30+00:00Added an answer on June 6, 2026 at 6:41 pm
    package com.exercise.AndroidCompass;
    
    import java.util.List;
    
    import android.app.Activity;
    import android.content.Context;
    import android.hardware.Sensor;
    import android.hardware.SensorEvent;
    import android.hardware.SensorEventListener;
    import android.hardware.SensorManager;
    import android.os.Bundle;
    import android.widget.Toast;
    
    public class AndroidCompass extends Activity {
    
    private static SensorManager mySensorManager;
    private boolean sersorrunning;
    private MyCompassView myCompassView;
    
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
    
         myCompassView = (MyCompassView)findViewById(R.id.mycompassview);
    
         mySensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
         List<Sensor> mySensors = mySensorManager.getSensorList(Sensor.TYPE_ORIENTATION);
    
         if(mySensors.size() > 0){
          mySensorManager.registerListener(mySensorEventListener, mySensors.get(0), SensorManager.SENSOR_DELAY_NORMAL);
          sersorrunning = true;
          Toast.makeText(this, "Start ORIENTATION Sensor", Toast.LENGTH_LONG).show();
    
         }
         else{
          Toast.makeText(this, "No ORIENTATION Sensor", Toast.LENGTH_LONG).show();
          sersorrunning = false;
          finish();
         }
     }
    
     private SensorEventListener mySensorEventListener = new SensorEventListener(){
    
    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {
     // TODO Auto-generated method stub
    
    }
    
    @Override
    public void onSensorChanged(SensorEvent event) {
     // TODO Auto-generated method stub
     myCompassView.updateDirection((float)event.values[0]);
    }
     };
    

    Source: http://android-er.blogspot.com/2010/08/simple-compass-sensormanager-and.html

    http://developer.android.com/reference/android/hardware/SensorManager.html

    Should be what you’re looking for. The OnSensorChanged method should provide the same functionality. (float)event.values[0] is your heading.

    Just read your bounty text. This is the only way to do it, from everything I’ve researched, and from my experience in general. The example I provided will give you what you need fairly quickly with copy & paste, however.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a web app for android using jquery_mobile. Is there any equivalent way
Is there any iOS Storyboard equivalent for Android development? iOS Storyboard is fantastic that
Is there any equivalent concept in WP7 as Android Intents? Basically, I want to
Is there and equivalent NSURLRequest (iOS) in android? So i can extend my class
Is there an Android equivalent of .NET's application.config? I am currently using a values
Is there any Android layout equivalent for HTML <HR /> tag?
Is there an equivalent of the iOS class NSNotificationCenter in Android ? Are there
Is there an equivalent in libGdx (in Android) like the touchdown event - so
Is there an equivalent to Java's null layout in Android? Basically I want to
Where can I find phonegap-1.3.0.js file iOS. In package it is there for Android.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.