我有一個onClickListener來創建一些按鈕,然後我想停止這個活動,但是因爲我在一個界面上,所以無法獲得活動Intent。從接口添加一個活動
那怎麼看起來像:
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
//blah blah blah
this.stopService(this.getIntent()); // <-- impossiblee, compliation error.
}
});
'this.stopService(getIntent());'或'this.stopService(YourActivityName.this.getIntent());' – Houcine
方法stopService是不是一個部分OnClickListener接口。 –
對不起,試試這個: 'stopService(getIntent());'或'YourActivityName.this.stopService(YourActivityName.this.getIntent());' – Houcine