Multiple MapActivity Elements on the Stack

I understand that this topic has been considered several times, and the often proposed solution to have "several" MapActivity classes is to run one in different processes. I do not want to do this, I have 3.

Instead, I redesigned one subclass of MapActivity to work in three different modes.


package com.rossgreenhalf.maptest.activity;

import android.os.Bundle;

import com.google.android.maps.MapActivity;

public class MyMapActivity extends MapActivity {

    @Override
    protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    /* Inflate xml view, Set Zoom etc */
    }

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

        int mode = getIntent().getExtras().getInt("MAP_MODE");

        switch(mode){
        case 1:
            /* Some markers to show */
            break;
        case 2:
            /* Just one Marker */
            break;
        case 3: 
            /* Only showing my location */
            break;
        }
    }

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

I allow multiple instances of MapActivity to be inside the task stack, as its launch mode is still set to Standard. This approach seems to work fine, and I don't get the Shutdown Connection Pool Shutdown message, which seems to be coming out, I'm a little confused as to whether there are actually multiple instances of MapActivity or if android is automatically used?

, , :


01-25 10:14:54.433: ERROR/ActivityThread(5620): Activity com.rossgreenhalf.maptest.activity.MyMapActivity has leaked IntentReceiver com.google.android.maps.NetworkConnectivityListener$ConnectivityBroadcastReceiver@44981cf0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-25 10:14:54.433: ERROR/ActivityThread(5620): android.app.IntentReceiverLeaked: Activity com.rossgreenhalf.maptest.activity.MyMapActivity has leaked IntentReceiver com.google.android.maps.NetworkConnectivityListener$ConnectivityBroadcastReceiver@44981cf0 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.ActivityThread$PackageInfo$ReceiverDispatcher.(ActivityThread.java:968)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.ActivityThread$PackageInfo.getReceiverDispatcher(ActivityThread.java:753)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:799)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:786)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:780)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:318)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at com.google.android.maps.NetworkConnectivityListener.startListening(MapActivity.java:163)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at com.google.android.maps.MapActivity.onResume(MapActivity.java:431)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at com.rossgreenhalf.maptest.activity.MyMapActivity.onResume(MyMapActivity.java:166)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1237)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.Activity.performResume(Activity.java:3864)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3315)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3340)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2158)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.os.Looper.loop(Looper.java:143)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at android.app.ActivityThread.main(ActivityThread.java:4914)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at java.lang.reflect.Method.invokeNative(Native Method)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at java.lang.reflect.Method.invoke(Method.java:521)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-25 10:14:54.433: ERROR/ActivityThread(5620):     at dalvik.system.NativeStart.main(Native Method)

? ?

+3

Source: https://habr.com/ru/post/1787649/


All Articles