Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are you missing a call to unregisterReceiver()? #184

Closed
arpit999bicubic opened this issue Dec 14, 2016 · 4 comments
Closed

Are you missing a call to unregisterReceiver()? #184

arpit999bicubic opened this issue Dec 14, 2016 · 4 comments

Comments

@arpit999bicubic
Copy link

When i press back button then i got this error

.StartTourActivity has leaked IntentReceiver com.mapbox.mapboxsdk.net.ConnectivityReceiver@24eeadc8 that was originally registered here. Are you missing a call to unregisterReceiver()?
                                                                     android.app.IntentReceiverLeaked: Activity com.bicubic.gincana.activity.StartTourActivity has leaked IntentReceiver com.mapbox.mapboxsdk.net.ConnectivityReceiver@24eeadc8 that was originally registered here. Are you missing a call to unregisterReceiver()?
                                                                         at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:903)
                                                                         at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:704)
                                                                         at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1650)
                                                                         at android.app.ContextImpl.registerReceiver(ContextImpl.java:1630)
                                                                         at android.app.ContextImpl.registerReceiver(ContextImpl.java:1624)
                                                                         at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:489)
                                                                         at com.mapbox.mapboxsdk.net.ConnectivityReceiver.instance(ConnectivityReceiver.java:35)
                                                                         at com.mapbox.mapboxsdk.MapboxAccountManager.start(MapboxAccountManager.java:53)
                                                                         at com.bicubic.gincana.activity.StartTourActivity.onCreate(StartTourActivity.java:77)
                                                                         at android.app.Activity.performCreate(Activity.java:6033)
                                                                         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2397)
                                                                         at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1310)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                         at android.os.Looper.loop(Looper.java:135)
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5268)
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at java.lang.reflect.Method.invoke(Method.java:372)
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)

it showing in this line MapboxAccountManager.start(this, getString(R.string.access_token));

here is my onCreate()

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Mapbox access token is configured here. This needs to be called either in your application
        // object or in the same activity which contains the mapview.
        MapboxAccountManager.start(this, getString(R.string.access_token));
        setContentView(R.layout.activity_start_tour);

        locationServices = LocationServices.getLocationServices(StartTourActivity.this);

        mapView = (MapView) findViewById(R.id.mapView);
        bt_main = (Button) findViewById(R.id.bt_main);
        bt_back = (Button) findViewById(R.id.bt_back);

        bt_main.setOnClickListener(this);
        bt_back.setOnClickListener(this);

        locationServices = LocationServices.getLocationServices(StartTourActivity.this);

        mapView.onCreate(savedInstanceState);
        mapView.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(MapboxMap mapboxMap) {
                map = mapboxMap;
                if (map != null) {
                    toggleGps(!map.isMyLocationEnabled());
                }

//                StartDialog newFragment = StartDialog.newInstance();
//                newFragment.setStyle(DialogFragment.STYLE_NORMAL, R.style.DialogAnimatiion);
//                newFragment.show((StartTourActivity.this).getFragmentManager(), "Image Dialog");


            }
        });
@cammace
Copy link
Contributor

cammace commented Dec 14, 2016

The MapboxAccountManager belongs in the application object. We have made the decision to keep it in each example in this app simply so users don't forget to add it. I also remember one of our engineers improving on this? Not sure where the ticket is though on Github.

@arpit999bicubic
Copy link
Author

So i need to use like this ?

MapboxAccountManager.start(getApplicationContext(), getString(R.string.access_token));

@cammace
Copy link
Contributor

cammace commented Dec 15, 2016

Yes similar to our testapp.

@cammace cammace closed this as completed Dec 15, 2016
@arpit999bicubic
Copy link
Author

Thanks for your quick prompt and help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants