相关疑难解决方法(0)

此Handler类应该是静态的,否则可能会发生泄漏:IncomingHandler

我正在开发一个带有服务的Android 2.3.3应用程序.我在服务中有这个与Main活动进行通信:

public class UDPListenerService extends Service
{
    private static final String TAG = "UDPListenerService";
    //private ThreadGroup myThreads = new ThreadGroup("UDPListenerServiceWorker");
    private UDPListenerThread myThread;
    /**
     * Handler to communicate from WorkerThread to service.
     */
    private Handler mServiceHandler;

    // Used to receive messages from the Activity
    final Messenger inMessenger = new Messenger(new IncomingHandler());
    // Use to send message to the Activity
    private Messenger outMessenger;

    class IncomingHandler extends Handler
    {
        @Override
        public void handleMessage(Message msg)
        {
        }
    }

    /**
     * Target we …
Run Code Online (Sandbox Code Playgroud)

android memory-leaks static-classes android-lint android-handler

287
推荐指数
4
解决办法
13万
查看次数

此Handler类应该是静态的,否则可能会发生泄漏(com.test.test3.ui.MainActivity.1)

我是android的新手,我尝试开发一个系统但是当我完成代码时,处理程序会显示此警告

下面显示我编辑后的代码,事件ontounch中的处理程序显示警告处理程序无法解析.我尝试将//忽略处理程序,我尝试运行应用程序并将其结果强制关闭.

public class MainActivity extends Activity {



protected static final int STOP = 100;
ImageView iv;
private ProgressBar pb;
LinearLayout ll;
private AnimationDrawable anim;
ScrollView sv;
private SQLiteDatabase db;
private boolean flagscanning = false;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ll = new LinearLayout(this);
    new HandlerClass(this);

            db = SQLiteDatabase.openDatabase(Environment.getExternalStorageDirectory()+"/antivirus.sqlite", null, SQLiteDatabase.OPEN_READONLY);  
            iv = (ImageView) this.findViewById(R.id.imageView1);
                    //???????
            pb = (ProgressBar) this.findViewById(R.id.progressBar1);
            ll = (LinearLayout) this.findViewById(R.id.ll);
                    //??ImageView?????????
            iv.setBackgroundResource(R.drawable.bg);
                    //sv???????????
            sv = (ScrollView) this.findViewById(R.id.scrollView1);
            anim = (AnimationDrawable) iv.getBackground();
}

private …
Run Code Online (Sandbox Code Playgroud)

android memory-leaks static-class android-handler

3
推荐指数
1
解决办法
9378
查看次数