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 3851484
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:10:11+00:00 2026-05-19T17:10:11+00:00

I am trying to transfer data from one page to another but some problem

  • 0

I am trying to transfer data from one page to another but some problem is coming below is the code. I am trying to transfer value of variable using bundle from first activity to second but something is wrong please tell me whats going wrong.

below is first activity:-

public class login extends Activity {
/** Called when the activity is first created. */

Context mCtx;
final static int START =0;

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    mCtx = this;


    Button btn = (Button)findViewById(R.id.btn);

    btn.setOnClickListener(new OnClickListener(){

    //  @Override
    public void onClick(View v)
    {
        String fromLat = new String();
        String fromLong = new String();
        String toLat = new String();
        String toLong = new String();


        fromLat = ((EditText)findViewById(R.id.FromLatitude)).getText().toString(); 
        fromLong = ((EditText)findViewById(R.id.FromLongitude)).getText().toString(); 
        toLat = ((EditText)findViewById(R.id.ToLatitude)).getText().toString(); 
        toLong = ((EditText)findViewById(R.id.ToLongitude)).getText().toString(); 



        Intent intent = new Intent(mCtx, MapRouteActivity.class);

         /*Sending some arguments*/ 
        Bundle bundle = new Bundle(4);

          bundle.putString("fromLat",fromLat );
          bundle.putString("fromLong",fromLong );
          bundle.putString("toLat",toLat );
          bundle.putString("toLong",toLong );

          intent.putExtras(bundle);

        /*Start Activity*/
        mCtx.startActivity(intent);

        /*Start ActivityForResult*/
        ((Activity)mCtx).startActivityForResult(intent, 2);
    }
});
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);

    if(requestCode == START)
    {

        Toast.makeText(mCtx, Integer.toString(resultCode), Toast.LENGTH_SHORT).show();
    }
}


@Override
public void onDestroy(){
    super.onDestroy();
    finish();
}
}

Below is the Second activity :-

public class MapRouteActivity extends MapActivity {

    LinearLayout linearLayout;
    MapView mapView;
    private Road mRoad;

    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.routeplanning);

            mapView = (MapView) findViewById(R.id.mapview);
            mapView.setBuiltInZoomControls(true);

            Bundle extras = this.getIntent().getExtras();
            String fLat=extras.getString("fromLat");
            String fLong=extras.getString("fromLong");
            String tLat=extras.getString("toLat");
            String tLong=extras.getString("toLong");

            final double fromLat=Double.parseDouble(fLat);
            final double fromLon=Double.parseDouble(fLong);
            final double toLat=Double.parseDouble(tLat);
            final double toLon=Double.parseDouble(tLong); 




            new Thread() {
                    @Override
                    public void run() {



                          //double fromLat = 28.6353, fromLon = 77.2250, toLat = 30.7313, toLon = 76.7754;
                            /***url contains the path to fetch the kml file from the internet*/
                            String url = RoadProvider
                                            .getUrl(fromLat, fromLon, toLat, toLon);
                            InputStream is = getConnection(url);
                            mRoad = RoadProvider.getRoute(is);
                            mHandler.sendEmptyMessage(0);
                    }
            }.start();
    }

    Handler mHandler = new Handler() {
            public void handleMessage(android.os.Message msg) {
                    TextView textView = (TextView) findViewById(R.id.description);
                    textView.setText(mRoad.mName + " " + mRoad.mDescription);
                    MapOverlay mapOverlay = new MapOverlay(mRoad, mapView);
                    List<Overlay> listOfOverlays = mapView.getOverlays();
                    listOfOverlays.clear();
                    listOfOverlays.add(mapOverlay);
                    mapView.invalidate();
            };
    };

    private InputStream getConnection(String url) {
            InputStream is = null;
            try {
                    //Opens a connection to the remote database(bidirectional)
                    URLConnection conn = new URL(url).openConnection();
                    is = conn.getInputStream();
            } catch (MalformedURLException e) {
                    e.printStackTrace();
            } catch (IOException e) {
                    e.printStackTrace();
            }
            return is;
    }

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

class MapOverlay extends com.google.android.maps.Overlay {
    Road mRoad;
    ArrayList<GeoPoint> mPoints;

    public MapOverlay(Road road, MapView mv) {
            mRoad = road;
            if (road.mRoute.length > 0) {
                    mPoints = new ArrayList<GeoPoint>();
                    for (int i = 0; i < road.mRoute.length; i++) {
                            mPoints.add(new GeoPoint((int) (road.mRoute[i][1] * 1000000),
                                            (int) (road.mRoute[i][0] * 1000000)));
                    }
                    int moveToLat = (mPoints.get(0).getLatitudeE6() + (mPoints.get(
                                    mPoints.size() - 1).getLatitudeE6() - mPoints.get(0)
                                    .getLatitudeE6()) / 2);
                    int moveToLong = (mPoints.get(0).getLongitudeE6() + (mPoints.get(
                                    mPoints.size() - 1).getLongitudeE6() - mPoints.get(0)
                                    .getLongitudeE6()) / 2);
                    GeoPoint moveTo = new GeoPoint(moveToLat, moveToLong);

                    MapController mapController = mv.getController();
                    mapController.animateTo(moveTo);
                    mapController.setZoom(9);
            }
    }

    @Override
    public boolean draw(Canvas canvas, MapView mv, boolean shadow, long when) {
            super.draw(canvas, mv, shadow);
            drawPath(mv, canvas);
            return true;
    }

    public void drawPath(MapView mv, Canvas canvas) {
            int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
            Paint paint = new Paint();
            paint.setColor(Color.GREEN);
            paint.setStyle(Paint.Style.STROKE);
            paint.setStrokeWidth(3);
            for (int i = 0; i < mPoints.size(); i++) {
                    Point point = new Point();
                    mv.getProjection().toPixels(mPoints.get(i), point);
                    x2 = point.x;
                    y2 = point.y;
                    if (i > 0) {
                            canvas.drawLine(x1, y1, x2, y2, paint);
                    }
                    x1 = x2;
                    y1 = y2;
            }
    }

}

On pressing the button the application is force closed.

Below is the LogCat data on force closing the application

02-02 15:32:31.837: ERROR/AndroidRuntime(199): Uncaught handler: thread main exiting due to uncaught exception
02-02 15:32:31.857: ERROR/AndroidRuntime(199): java.lang.NullPointerException
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at route.planning.login$1.onClick(login.java:49)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.view.View.performClick(View.java:2344)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.view.View.onTouchEvent(View.java:4133)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.widget.TextView.onTouchEvent(TextView.java:6504)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.view.View.dispatchTouchEvent(View.java:3672)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1712)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1202)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.app.Activity.dispatchTouchEvent(Activity.java:1987)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1696)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1658)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.os.Looper.loop(Looper.java:123)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at android.app.ActivityThread.main(ActivityThread.java:4203)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at java.lang.reflect.Method.invokeNative(Native Method)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at java.lang.reflect.Method.invoke(Method.java:521)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
02-02 15:32:31.857: ERROR/AndroidRuntime(199):     at dalvik.system.NativeStart.main(Native Method)
  • 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-19T17:10:12+00:00Added an answer on May 19, 2026 at 5:10 pm

    Whats in the line 49 of login.java?

    Some advice: Classes should always start with upper case so Login instead of login

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

Sidebar

Related Questions

Trying to setup an SSH server on Windows Server 2003. What are some good
Trying to find some simple SQL Server PIVOT examples. Most of the examples that
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
Trying to honor a feature request from our customers, I'd like that my application,
Trying to get my css / C# functions to look like this: body {
Trying to make a make generic select control that I can dynamically add elements
Trying to keep all the presentation stuff in the xhtml on this project and
Trying to make a MySQL-based application support MS SQL, I ran into the following
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to perform a single boolean NOT operation, it appears that under MS SQL

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.