求助,這個錯誤的原因是什么?
import android.app.Activity;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity {
Intent intent1;
Intent intent2;
@Override
? ? protected void onCreate(Bundle savedInstanceState) {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.activity_main);
? ? ?
? ? ?
? ? ?
}
public void ?click(View v){
switch(v.getId()){
case R.id.startS:
intent1=new Intent(MainActivity.this, myService.class);
startService(intent1);
break;
case R.id.stopS:
stopService(intent1);
break;
case R.id.bind:
intent2=new Intent(MainActivity.this, myService2.class);
bindService(intent2, null, Service.BIND_AUTO_CREATE);
break;
case R.id.unbind:
unbindService(null);
break;
}
}
}
2015-08-19
bindService(intent2, null, Service.BIND_AUTO_CREATE);?? 這句不能傳null進去,我也遇到了,可能是版本問題,有些版本不允許null值。
2016-05-03
最后是怎么解決的 ,我把視頻后面的代碼補進去了,傳conn,可是點擊BindService的按鈕時還是報錯java.lang.IllegalStateException: Could not execute method of the activity
2016-03-08
那應該傳啥?