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

  • SEARCH
  • Home
  • 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 773575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:59:13+00:00 2026-05-14T18:59:13+00:00

I’m trying to pass a bundle of two values from a started class to

  • 0

I’m trying to pass a bundle of two values from a started class to my landnav app, but according to the debug nothing is getting passed, does anyone have any ideas why?

package edu.elon.cs.mobile;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class PointEntry extends Activity{

private Button calc;
private EditText longi;
private EditText lati;
private double longid;
private double latd;


public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pointentry);

    calc = (Button) findViewById(R.id.coorCalcButton);
    calc.setOnClickListener(landNavButtonListener);

    longi = (EditText) findViewById(R.id.longitudeedit);
    lati = (EditText) findViewById(R.id.latitudeedit);
}

private void startLandNav() {

    Intent intent = new Intent(this, LandNav.class);
    startActivityForResult(intent, 0);
}


private OnClickListener landNavButtonListener = new OnClickListener() {

    @Override
    public void onClick(View arg0) {
        Bundle bundle = new Bundle();
        bundle.putDouble("longKey", longid);
        bundle.putDouble("latKey", latd);
        longid = Double.parseDouble(longi.getText().toString());
        latd = Double.parseDouble(lati.getText().toString());
        startLandNav();
    }


};

}

This is the class that is suppose to take the second point

   package edu.elon.cs.mobile;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;
import android.widget.TextView;

public class LandNav extends MapActivity{
    private MapView map;
    private MapController mc;
    private GeoPoint myPos;
    private SensorManager sensorMgr;
    private TextView azimuthView;

    private double longitudeFinal;
    private double latitudeFinal;
    double startTime;
    double newTime;
    double elapseTime;
    private MyLocationOverlay me;
    private Drawable marker;
    private GeoPoint finalPos;
    private SitesOverlay myOverlays;

    public LandNav(){
        startTime = System.currentTimeMillis();


    }


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.landnav);

        Bundle bundle = this.getIntent().getExtras();

        if(bundle != null){
            longitudeFinal = bundle.getDouble("longKey");
            latitudeFinal = bundle.getDouble("latKey");
        }

        azimuthView = (TextView) findViewById(R.id.azimuthView);
        map = (MapView) findViewById(R.id.map);
        mc = map.getController();

        sensorMgr = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

        LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
        Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        int longitude = (int)(location.getLongitude() * 1E6);
        int latitude =  (int)(location.getLatitude() * 1E6);

        finalPos = new GeoPoint((int)(latitudeFinal*1E6), (int)(longitudeFinal*1E6));
        myPos = new GeoPoint(latitude, longitude);
        map.setSatellite(true);
        map.setBuiltInZoomControls(true);
        mc.setZoom(16);
        mc.setCenter(myPos);

        marker = getResources().getDrawable(R.drawable.greenmarker);
        marker.setBounds(0,0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());

        me = new MyLocationOverlay(this, map);
        myOverlays = new SitesOverlay(marker, myPos, finalPos);

        map.getOverlays().add(myOverlays);
    }

    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }

    @Override
    protected void onResume() {
        super.onResume();
        sensorMgr.registerListener(sensorListener,
                sensorMgr.getDefaultSensor(Sensor.TYPE_ORIENTATION),
                SensorManager.SENSOR_DELAY_UI);

        me.enableCompass();
        me.enableMyLocation();
        //me.onLocationChanged(location)

    }

    protected void onPause(){
        super.onPause();
        me.disableCompass();
        me.disableMyLocation();
    }

    @Override
    protected void onStop() {
        super.onStop();
        sensorMgr.unregisterListener(sensorListener);
    }

    private SensorEventListener sensorListener = new SensorEventListener() {

        @Override
        public void onAccuracyChanged(Sensor arg0, int arg1) {
            // TODO Auto-generated method stub  
        }

        private boolean reset = true;

        @Override
        public void onSensorChanged(SensorEvent event) {
            newTime = System.currentTimeMillis();
            elapseTime = newTime - startTime;
            if (event.sensor.getType() == Sensor.TYPE_ORIENTATION && elapseTime > 400) {
                azimuthView.setText(Integer.toString((int) event.values[0]));
                startTime = newTime;
            }
        }   
    };

}
  • 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-05-14T18:59:14+00:00Added an answer on May 14, 2026 at 6:59 pm

    You are not passing the Bundle you create. You have to do something like this:

    private void startLandNav(Bundle b) {
        Intent intent = new Intent(this, LandNav.class);
        intent.putExtras(b);
        startActivityForResult(intent, 0);
    }
    
    private OnClickListener landNavButtonListener = new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            Bundle bundle = new Bundle();
            bundle.putDouble("longKey", longid);
            bundle.putDouble("latKey", latd);
            longid = Double.parseDouble(longi.getText().toString());
            latd = Double.parseDouble(lati.getText().toString());
            startLandNav(bundle);
        }
    };
    

    Edit: By the way, in this case you are creating a bundle that will die soon and that does not have too much data… so you can consider using putExtra(name, value) method so that you can pass data directly to the Intent. For example: intent.putExtra("latKey", latd);

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

Sidebar

Related Questions

No related questions found

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.