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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:35:27+00:00 2026-06-07T08:35:27+00:00

I have a listview and onItemSelected , will call an Activity to get user

  • 0

I have a listview and onItemSelected, will call an Activity to get user location (his current lat and lng), this activity has no layout, then this activity automatically calls another activity which gets lat and lng of the item selected from the listview and marks both the user location and item location on the map.

This worked fine when I was testing on Emulator and Samsung Galaxy Ace, But it crashes when I’m testing on Micromax A50 and Sony Xperia.

Sad thing is that I can’t install drivers of the later 2 devices, so I cant get logcat.
Can any 1 guess what might have gone wrong??

My code for finding user location is:

public class MyLocationActivity extends Activity implements LocationListener {
    private LocationManager mgr;
    private String best;
    public static double myLocationLatitude;
    public static double myLocationLongitude;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mgr = (LocationManager) getSystemService(LOCATION_SERVICE);

        dumpProviders();

        Criteria criteria = new Criteria();

        best = mgr.getBestProvider(criteria, true);
        Log.d("best provider", best);

        Location location = mgr.getLastKnownLocation(best);
        dumpLocation(location);

        /*Intent intent = new Intent(MyLocationActivity.this, ShowMapActivity.class);
        startActivity(intent);*/

        Intent intent = new Intent(MyLocationActivity.this, MapMarkerActivity.class);
        startActivity(intent);
        finish();
    }

    public void onLocationChanged(Location location) {
        // TODO Auto-generated method stub
        dumpLocation(location);

    }

    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }

    @Override
    protected void onPause() {

        super.onPause();
        mgr.removeUpdates(this);
    }

    @Override
    protected void onResume() {

        super.onResume();
        mgr.requestLocationUpdates(best, 15000, 1, this);
    }

    private void dumpLocation(Location l) {

        if (l == null) {

            myLocationLatitude = 0.0;
            myLocationLongitude = 0.0;
        } else {

            myLocationLatitude = l.getLatitude();
            myLocationLongitude = l.getLongitude();
        }
    }

    private void dumpProviders() {

        List<String> providers = mgr.getAllProviders();
        for (String p : providers) {

            dumpProviders(p);
        }
    }

    private void dumpProviders(String s) {

        LocationProvider info = mgr.getProvider(s);
        StringBuilder builder = new StringBuilder();
        builder.append("name: ").append(info.getName());
    }

}

and item location is:

public class MapMarkerActivity extends MapActivity {

    private MapView map = null;
    private MyLocationOverlay me = null;
    private Drawable marker1;
    private Drawable marker2;

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

        Button feedButton = (Button) findViewById(R.id.feedButton_particularEntry);
        feedButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {

                Intent intent = new Intent(MapMarkerActivity.this,
                        FeedListViewActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                startActivity(intent);
            }
        });

        Button iWantButton = (Button) findViewById(R.id.iWantButton_particularEntry);
        iWantButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent intent = new Intent(MapMarkerActivity.this,
                        IWantActivity.class);
                startActivity(intent);
            }
        });

        Button shareButton = (Button) findViewById(R.id.shareButton_particularEntry);
        shareButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent intent = new Intent(MapMarkerActivity.this,
                        ShareActivity.class);
                startActivity(intent);
            }
        });

        Button profileButton = (Button) findViewById(R.id.profileButton_particularEntry);
        profileButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent intent = new Intent(MapMarkerActivity.this,
                        ProfileActivity.class);
                startActivity(intent);
            }
        });

        map = (MapView) findViewById(R.id.map);

        map.getController().setCenter(
                getPoint(FeedListViewActivity.lat, FeedListViewActivity.lng));
        map.getController().setZoom(13);
        map.setBuiltInZoomControls(true);

        marker1 = getResources().getDrawable(R.drawable.marker2);

        marker2 = getResources().getDrawable(R.drawable.marker1);

        marker1.setBounds(0, 0, marker1.getIntrinsicWidth(),
                marker1.getIntrinsicHeight());
        marker2.setBounds(0, 0, marker1.getIntrinsicWidth(),
                marker1.getIntrinsicHeight());

        map.getOverlays().add(new SitesOverlay(marker1));

        me = new MyLocationOverlay(this, map);
        map.getOverlays().add(me);
    }

    @Override
    public void onResume() {
        super.onResume();

        me.enableCompass();
    }

    @Override
    public void onPause() {
        super.onPause();

        me.disableCompass();
    }

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

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_S) {
            map.setSatellite(!map.isSatellite());
            return (true);
        } else if (keyCode == KeyEvent.KEYCODE_Z) {
            map.displayZoomControls(true);
            return (true);
        }

        return (super.onKeyDown(keyCode, event));
    }

    private GeoPoint getPoint(double lat, double lon) {
        return (new GeoPoint((int) (lat * 1000000.0), (int) (lon * 1000000.0)));
    }

    public class SitesOverlay extends ItemizedOverlay<OverlayItem> {
        private List<OverlayItem> items = new ArrayList<OverlayItem>();

        public SitesOverlay(Drawable marker) {
            super(marker);

            boundCenterBottom(marker);

            OverlayItem oli1 = new OverlayItem(getPoint(
                    MyLocationActivity.myLocationLatitude,
                    MyLocationActivity.myLocationLongitude), "YL",
                    "Your Location");
            oli1.setMarker(marker2);
            items.add(oli1);

            OverlayItem oli2 = new OverlayItem(getPoint(
                    FeedListViewActivity.lat, FeedListViewActivity.lng), "SL",
                    "Store Location");
            oli2.setMarker(marker1);
            items.add(oli2);

            populate();
        }

        @Override
        protected OverlayItem createItem(int i) {
            return (items.get(i));
        }

        @Override
        protected boolean onTap(int i) {
            Toast.makeText(MapMarkerActivity.this, items.get(i).getSnippet(),
                    Toast.LENGTH_SHORT).show();

            return (true);
        }

        @Override
        public int size() {
            return (items.size());
        }
    }
}
  • 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-07T08:35:28+00:00Added an answer on June 7, 2026 at 8:35 am

    Maybe this can help you:
    Location Method Calls Crashes On Some Devices

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

Sidebar

Related Questions

I have an activity which have ListView. When I want to access this ListView
I have listview control.There is an option to remove selected items.After the user removes
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have ListView in my project which has ListItems as in the form of
I have a ListView with Horizontal WrapPanel as its ItemsPanelTemplate. I want to get
I have ListView activity class: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String[] naziviMolitvi =
I have ListView. Every row has TextView with some text. And also by default
I have a listview that has multiple entries and each entry has 2 subitems.
I have a ListView that has two columns, one for a zone name and
I have ListView which shows images from an ImageList. Now wanted to get index

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.