AlertDialog.Builder中的Android stopService()

时间:2013-06-30 13:41:57

标签: java android android-intent android-activity android-service

您好我正在开发一个应用程序,我需要将我的stopService();在AlertDialog.Builder中的PositiveButton但我收到一个错误,我的代码是:

....其他代码

.setPositiveButton("Yes",newDialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,int id)
   {                                                                        

     finish();
     System.exit(0);                                    
     stopService(new Intent(this, Service.class));
  }
}

....其他代码

1 个答案:

答案 0 :(得分:1)

尝试

public void onClick(DialogInterface dialog,int id)
   {                                                                        

       stopService(new Intent(<InsertYourActivityClassName>.this, Service.class));
       finish();                               

  }
相关问题