曲を開始/停止するサービスを作成しました。「情報」をクリックすると、従軍星章が正しく表示されますが、停止できません。「publicvoidonClick」内でサービスを停止する意図を置く必要がありますが、エラーが発生しました。
これは、サービスを停止するコードです。stopService(new Intent(this、SobService.class));
private void Info(){
startService(new Intent(this, SobService.class));
LayoutInflater li = LayoutInflater.from(this);
View view = li.inflate(R.layout.info, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view).create();
TextView text=(TextView) findViewById(R.id.infoView1);
builder.setCancelable(false);
builder.setPositiveButton("Chiudi", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id) {
//stopService(new Intent(this, SobService.class));
dialog.cancel();
}
});
builder.show();