简体   繁体   中英

Android show google map problem!

Hi * I need to show a map by passing the address. however, in some cases, the whole app will be forced to close. it may be because of gecoding the address to coordinate. My question is what is the best way to handle the exception while calling the map? The following function is my function for getting the gecoder results.however, it is still not perfect. what should i do in order to avoid the shut down of the app? thanks a lot!! penny

private void findLocation(final String locationName) {
    Thread thrd = new Thread() {
        @Override
        public void interrupt() {
            super.interrupt();
        }

        @Override
        public void run() {

            try {
                addressList = geocoder.getFromLocationName(locationName, 2);
            } catch (IOException e) {

                MyLog.e(e.getMessage());
            }

            uiCallback.sendEmptyMessage(0);

        }
    };
    thrd.start();
}

Most likely your app is crashing due to a RuntimeException. Can you add a stacktrace of the actual crash ? Your code only handles the IOException by logging it. If another (Runtime)Exception occurs, your app can still crash as it's not properly handled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM