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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:27:23+00:00 2026-06-18T01:27:23+00:00

I have a problem,My current location address its displayed a textView But problem is

  • 0

I have a problem,My current location address its displayed a textView

But problem is After clicking on the send button, Error will come

But i want to Send my current location via email with google map hyperlink

please check my problem,please send me any solution

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
 // making it full screen
    requestWindowFeature(Window.FEATURE_NO_TITLE);        
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);
   ........
 }
 @Override
public void onLocationChanged(Location location) {
    TextView tvLocation = (TextView) findViewById(R.id.tv_location);

    String address = "";
    Geocoder geoCoder = new Geocoder(
            getBaseContext(), Locale.getDefault());

    // Getting latitude
    double latitude = location.getLatitude();

    // Getting longitude
    double longitude = location.getLongitude();

    // Creating an instance of GeoPoint corresponding to latitude and longitude
    GeoPoint point = new GeoPoint((int)(latitude * 1E6), (int)(longitude*1E6));

    try {
        List<Address> addresses = geoCoder.getFromLocation(
            point.getLatitudeE6()  / 1E6, 
            point.getLongitudeE6() / 1E6, 1);

            if (addresses.size() > 0) {
                for (int index = 0; index < addresses.get(0).getMaxAddressLineIndex(); index++)
                    address += addresses.get(0).getAddressLine(index) + " ";
            }
            tvLocation.setText("Address :" +  address  );
    }
    catch (IOException e) {                
        e.printStackTrace();
    }
    // Setting latitude and longitude in the TextView tv_location
    tvLocation.setText("Latitude:" +  latitude  + ", Longitude:"+ longitude +", Add :"+ address );

    // Getting MapController
    MapController mapController = mapView.getController();

    // Locating the Geographical point in the Map
    mapController.animateTo(point);

    // Applying a zoom
    mapController.setZoom(15);

    // Redraw the map
    mapView.invalidate();

    // Getting list of overlays available in the map
    List<Overlay> mapOverlays = mapView.getOverlays();

    // Creating a drawable object to represent the image of mark in the map
    Drawable drawable = this.getResources().getDrawable(R.drawable.cur_position);

    // Creating an instance of ItemizedOverlay to mark the current location in the map
    CurrentLocationOverlay currentLocationOverlay = new CurrentLocationOverlay(drawable);

    // Creating an item to represent a mark in the overlay
    OverlayItem currentLocation = new OverlayItem(point, "Current Location", "Latitude : " + latitude + ", Longitude:" + longitude);

    // Adding the mark to the overlay
    currentLocationOverlay.addOverlay(currentLocation);

    // Clear Existing overlays in the map
    mapOverlays.clear();

    // Adding new overlay to map overlay
   mapOverlays.add(currentLocationOverlay); 

}

public void onSendLocationEmail(View button) {

    final TextView txtview = (TextView) findViewById(R.id.tv_location);
    String txt = txtview.getText().toString();

    // Take the fields and format the message contents
    String subject = formatSubject(txt);
    String message = formatMessage(txt);

    sendMessage(subject, message);
    Toast.makeText(getApplicationContext(),"Clicked Send Email Button" + "-", Toast.LENGTH_SHORT).show();
} 

private String formatSubject(String txt) {

    String strSubjectFormat = getResources().getString(R.string.mapsubject_format);

    String strSubject = String.format(strSubjectFormat, txt);

    return strSubject;

}

private String formatMessage(String txt) {
    String strFormatMsg = getResources().getString(R.string.mapbody_format);

 //String strRequiresResponse = getResponseString(bRequiresResponse);

    String strMsg = String.format(strFormatMsg, txt);

    return strMsg;

}

private void sendMessage(String subject, String message) {
    Intent messageIntent = new Intent(android.content.Intent.ACTION_SEND);

    CharSequence location = lastLocation.getLatitudeE6()/ 1E6 + "," + lastLocation.getLongitudeE6()/ 1E6;

    String aEmailList[] = { "srinivasareddy1250@gmail.com" };
    messageIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);

    messageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);

    messageIntent.setType("plain/text");
    messageIntent.putExtra(android.content.Intent.EXTRA_TEXT, message + "http://maps.google.comk/maps/maps?q=loc:"+location);

}

This is my error

Unfortunately project has stopped

01-29 07:34:39.439: E/AndroidRuntime(3693): FATAL EXCEPTION: main
01-29 07:34:39.439: E/AndroidRuntime(3693): java.lang.IllegalStateException: Could not execute method of the activity
01-29 07:34:39.439: E/AndroidRuntime(3693):     at android.view.View$1.onClick(View.java:3597)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at android.view.View.performClick(View.java:4202)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at android.view.View$PerformClick.run(View.java:17340)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at android.os.Handler.handleCallback(Handler.java:725)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at android.os.Looper.loop(Looper.java:137)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at android.app.ActivityThread.main(ActivityThread.java:5039)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at java.lang.reflect.Method.invokeNative(Native Method)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at java.lang.reflect.Method.invoke(Method.java:511)
 01-29 07:34:39.439: E/AndroidRuntime(3693):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at dalvik.system.NativeStart.main(Native Method)
01-29 07:34:39.439: E/AndroidRuntime(3693): Caused by: java.lang.reflect.InvocationTargetException
01-29 07:34:39.439: E/AndroidRuntime(3693):     at java.lang.reflect.Method.invokeNative(Native Method)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at java.lang.reflect.Method.invoke(Method.java:511)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at android.view.View$1.onClick(View.java:3592)
01-29 07:34:39.439: E/AndroidRuntime(3693):     ... 11 more
01-29 07:34:39.439: E/AndroidRuntime(3693): Caused by: java.lang.NullPointerException
 01-29 07:34:39.439: E/AndroidRuntime(3693):    at com.sygnet.locationingooglemap.MainActivity.sendMessage(MainActivity.java:219)
01-29 07:34:39.439: E/AndroidRuntime(3693):     at com.sygnet.locationingooglemap.MainActivity.onSendLocationEmail(MainActivity.java:191)
01-29 07:34:39.439: E/AndroidRuntime(3693):     ... 14 more
  • 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-18T01:27:24+00:00Added an answer on June 18, 2026 at 1:27 am

    This is the full code of a current location address

    Check this code…

      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
     // making it full screen
        requestWindowFeature(Window.FEATURE_NO_TITLE);        
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
    
        // Getting reference to MapView
        mapView = (MapView) findViewById(R.id.map_view);
    
        // Setting Zoom Controls on MapView
        mapView.setBuiltInZoomControls(true);
    
    
    
        List<Overlay> mapOverlays = mapView.getOverlays();
        mlo = new MyLocationOverlay(this.getApplicationContext(),mapView);
    
        if(!mlo.enableMyLocation()){
                Toast.makeText(this, R.string.toast, Toast.LENGTH_LONG).show();
                this.finish();
        }
        mlo.enableCompass();
        mapOverlays.add(mlo);
    
          ......
    
      }  
      @Override
    public void onLocationChanged(Location location) {
        tvLocation = (TextView) findViewById(R.id.tv_location);
    
        String address = "";
        Geocoder geoCoder = new Geocoder(
                getBaseContext(), Locale.getDefault());
    
        // Getting latitude
        latitude = location.getLatitude();
    
        // Getting longitude
        longitude = location.getLongitude();
    
        // Creating an instance of GeoPoint corresponding to latitude and longitude
        point = new GeoPoint((int)(latitude * 1E6), (int)(longitude*1E6));
    
        try {
            List<Address> addresses = geoCoder.getFromLocation(
                point.getLatitudeE6()  / 1E6, 
                point.getLongitudeE6() / 1E6, 1);
    
                if (addresses.size() > 0) {
                    for (int index = 0; index < addresses.get(0).getMaxAddressLineIndex(); index++)
                        address += addresses.get(0).getAddressLine(index) + " ";
                }
                tvLocation.setText("Address :" +  address  );
        }
        catch (IOException e) {                
            e.printStackTrace();
        }
        // Setting latitude and longitude in the TextView tv_location
        tvLocation.setText("Latitude:" +  latitude  + ", Longitude:"+ longitude +", Address :"+ address );
    
        // Getting MapController
        MapController mapController = mapView.getController();
    
        // Locating the Geographical point in the Map
        mapController.animateTo(point);
    
        // Applying a zoom
        mapController.setZoom(15);
    
        // Redraw the map
        mapView.invalidate();
    
        // Getting list of overlays available in the map
        List<Overlay> mapOverlays = mapView.getOverlays();
    
        // Creating a drawable object to represent the image of mark in the map
        Drawable drawable = this.getResources().getDrawable(R.drawable.cur_position);
    
        // Creating an instance of ItemizedOverlay to mark the current location in the map
        CurrentLocationOverlay currentLocationOverlay = new CurrentLocationOverlay(drawable);
    
        // Creating an item to represent a mark in the overlay
        OverlayItem currentLocation = new OverlayItem(point, "Current Location", "Latitude : " + latitude + ", Longitude:" + longitude);
    
        // Adding the mark to the overlay
        currentLocationOverlay.addOverlay(currentLocation);
    
        // Clear Existing overlays in the map
        mapOverlays.clear();
    
        // Adding new overlay to map overlay
       mapOverlays.add(currentLocationOverlay);         
    }
    
    public void onSendLocationEmail(View button) {      
    
        String txt = tvLocation.getText().toString();
    
        // Take the fields and format the message contents
        String subject = formatSubject(txt);
        String message = formatMessage(txt);
    
        sendMessage(subject, message, location);
        Toast.makeText(getApplicationContext(),"Clicked Send Email Button" + "-", Toast.LENGTH_SHORT).show();
    } 
    
    private String formatSubject(String txt) {
    
        String strSubjectFormat = getResources().getString(R.string.mapsubject_format);
    
        String strSubject = String.format(strSubjectFormat, txt);
    
        return strSubject;
    
    }
    
    private String formatMessage(String txt) {
        String strFormatMsg = getResources().getString(R.string.mapbody_format);
    
        String strMsg = String.format(strFormatMsg, txt);
    
        return strMsg;  
    } 
    
    private void sendMessage(String subject, String message,Location location) {
    
         try {
        Intent messageIntent = new Intent(android.content.Intent.ACTION_SEND);
        messageIntent.setType("plain/text");        
    
        String aEmailList[] = { "mailId@gmail.com" };
        messageIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
    
        messageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    
        messageIntent.putExtra(android.content.Intent.EXTRA_TEXT, 
                message + "http://maps.google.com/maps?q=loc:" + latitude +","+ longitude);
        startActivity(Intent.createChooser(messageIntent, "Send mail..."));
    }
         catch (Exception e) {
                Log.e(LOG_TAG, "sendPictureMessage() failed to start activity.", e);
                Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_LONG).show();
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here I create one project that will track our current location. But I have
I have a problem with obtaining the current user location. Code at first works
I've been working on an app which basically will send current location to a
I want to show user's current location with iphone gps feature but problem is
I have a problem. In my app i need current location from a user.
The following code summarizes the problem I have at the moment. My current execution
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
I have worked many projects with no problems. But in current project, I tested
I have problem with repopulating form_upload after validation. Other input fields or selectboxes are
I am a beginner in Android. I have developed a application that will send

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.