Hi I am developing an App and I need to put my stopService(); in PositiveButton in AlertDialog.Builder but I get a error , My code is :
.... Other Code
.setPositiveButton("Yes",newDialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id)
{
finish();
System.exit(0);
stopService(new Intent(this, Service.class));
}
}
.... Other Code
Try
public void onClick(DialogInterface dialog,int id)
{
stopService(new Intent(<InsertYourActivityClassName>.this, Service.class));
finish();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.