您好,我正在开发一个应用程序,我需要将我的 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));
}
}
....其他代码
最佳答案
尝试
public void onClick(DialogInterface dialog,int id)
{
stopService(new Intent(<InsertYourActivityClassName>.this, Service.class));
finish();
}
关于java - AlertDialog.Builder 中的 Android stopService(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17390959/