Android 如何停止活动中的服务

Android 如何停止活动中的服务,android,Android,*我是在点击按钮时写这段代码的 public void onstopServiceClickHandler(View view){ Intent intent=new Intent(DownloadQueueActivity.this, ProductDownloadService.class); stopService(intent); //lv_productList.setAdapter(downloadQueu

*我是在点击按钮时写这段代码的

public void onstopServiceClickHandler(View view){       
        Intent intent=new Intent(DownloadQueueActivity.this, ProductDownloadService.class);
        stopService(intent);        
        //lv_productList.setAdapter(downloadQueueAdapter);
        //startServiceButton.setVisibility(View.VISIBLE);
        Toast.makeText(_instance, "click stop service",Toast.LENGTH_SHORT).show();
    }*

但是调用了服务方法onDestory。服务未停止。请帮助我如何在活动中停止服务

尝试此按钮单击..

button.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
               Intent intent=new Intent(DownloadQueueActivity.this, ProductDownloadService.class);
        stopService(intent);
             }
         });
当你打电话的时候

 stopService(new Intent(this, MyService.class));
只要他能,服务就会停止


一旦请求使用stopSelf()或stopService()停止,系统将尽快销毁服务。这是来自

您的按钮单击很奇怪,我从未见过,请跟我来。。