0

アプリを起動すると、マップが正常に読み込まれます。ここで、ネットワーク接続を停止し、いくつかの画面をスライドさせて、再びネットワーク接続を開始しました。画面をスライドさせると、NullPointerException が発生します。onResume が呼び出されたときにマップをロードできません。

onCreateで私はこのようにやっています

@Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.cityattractions);
        Utils utils = new Utils();
        if (getIntent() != null && getIntent().getBooleanExtra("EXIT", false)) {
             finish();


            if(utils.getUserAcceptance(this)){
            utils.cleanUpSession();
            activity = this;
            context = this;
            Log.d(TAG, "onCreate");
            utils.loadStartUpInfo(this);
            Intent intent = getIntent();
            Bundle b = intent.getExtras();
            String moduleName = null;

            MapView mapView = (MapView) activity.findViewById(R.id.defaultmapView);
            mapView.setVisibility(View.GONE);

            if (b != null) {
                moduleName = b.getString("neighborhood");
            }

            MenuUtils menuUtils = new MenuUtils();
            ((ImageView) findViewById(R.id.custom_menu)).setOnTouchListener(new OpenPopup(this));
            if (moduleName != null && moduleName.equalsIgnoreCase("myneighbor")) {

                setMyNeighborHoodLocation();
                new Utils().loadCityNames(activity, -1, -1, -1, null, 0, true);
                new MapUtils().drawMap(this);
            } else {

                manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                listener = new ManageLocation();    
                listener.setSucessCallBack(this, "setLocation");
                listener.setFailureCallBack(this, "setNoLocation");

                manager.requestLocationUpdates(
                        utils.getCurrentPlaceLocationProvider(manager), 0, 0,
                        listener);

そして onResume で私は以下のようにやっています

protected void onResume() {

        super.onResume();

        Utils utils = new Utils();
        if (new Utils().isConnectionAvailable(activity)) {  
        manager.requestLocationUpdates(
                utils.getCurrentPlaceLocationProvider(manager), 0, 0,
                listener); }

                    new MapUtils().drawMap(this);
                }

onPause() メソッドで LocationListener の登録を解除しようとしました。しかし、何も機能していないようです。誰かが私を正しい方向に向けることができますか?

ここに私のlogcatがあります

 Caused by: java.lang.NullPointerException
01-28 18:41:02.013: E/AndroidRuntime(32082):    at org.appright.mycity.maps.MapUtils.drawMap(MapUtils.java:59)
01-28 18:41:02.013: E/AndroidRuntime(32082):    at org.appright.mycity.activity.CityAttractions.onResume(CityAttractions.java:500)
01-28 18:41:02.013: E/AndroidRuntime(32082):    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1199)
01-28 18:41:02.013: E/AndroidRuntime(32082):    at android.app.Activity.performResume(Activity.java:5280)
01-28 18:41:02.013: E/AndroidRuntime(32082):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2606)
01-28 18:41:02.013: E/AndroidRuntime(32082):    ... 10 more
4

0 に答える 0