android.app.IntentReceiverLeaked:Activity com.example.brown

android.app.IntentReceiverLeaked:Activity com.example.brown,android,android-intent,android-mapview,Android,Android Intent,Android Mapview,朋友的, 我在地图视图中遇到了这个问题,最初我在标题中使用带有搜索选项的地图视图来搜索我正在使用的内容 这里是我的搜索代码 Intent intent = getIntent(); findViewById(R.id.map_search).setOnClickListener( new OnClickListener() { public void onClick(View v) {

朋友的, 我在地图视图中遇到了这个问题,最初我在标题中使用带有搜索选项的地图视图来搜索我正在使用的内容 这里是我的搜索代码

Intent intent = getIntent();

        findViewById(R.id.map_search).setOnClickListener(

                    new OnClickListener() {
                        public void onClick(View v) {

                        onSearchRequested();
                        }
                    });
单击后,执行下面的代码

       if (Intent.ACTION_VIEW.equals(intent.getAction())) {
            //              
            word = intent.getDataString();

            Log.v("Search2", word);
            Cursor c = managedQuery(Constants.CONTENT_URI_MAPS, null,
                    Constants.BNAME + "='" + word + "'", null,                         null);
-------------- } 在这里,我从数据库中获取搜索列表数据。 搜索选项提供搜索地图结果,并且在搜索页面中标题中再次出现搜索选项和返回按钮,当从UI或设备中单击返回按钮时,它会返回到上一个mapview,并在第一个mapview中再次返回按钮,当单击返回时,会引发Activitythread异常, 09-16 16:04:17.088:错误/ActivityThread(425):Activity com.example.brown.Bru\u Maps\u结果泄漏了IntentReceiver android.net.NetworkConnectionyListener$ConnectivityBroadcastReceiver@43898578原来是在这里注册的。您是否错过了对unregisterReceiver()的调用?
我想我必须重写Onpause()、OnReceive()方法,但我不知道如何实现它。请帮助我解决此问题。

在某些地方,您没有为相应的“registerReceiver”调用调用“unRegisterReceiver”方法


调用registerReceiver API以侦听广播目的,您可以检查代码中是否正在执行此操作吗?

我确信您忘记了取消注册Receiver()

尽管如此,如果在Activity.onResume()实现中注册接收者,则应在Activity.onPause()中注销该接收者。
这样,暂停时就不会收到意图,这将减少不必要的系统开销

嗨..我从来没有用过broadcastreceiver,我用的是简单的Intent=getIntent();我如何使用unregisterreceiver来达到目的,请帮助我。