我的应用程序中有以下代码:
.... tb1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Auto-generated method stub
startService(Intent this.Main);
}
});
}
public void onStart(Intent intent, int startid) {
Toast.makeText(context, "yessssss", Toast.LENGTH_LONG).show();
//and do something//
}
当用户单击“tb1”按钮时,我想启动服务,
我试过了:
startService(new Intent(this, Main.class));
和
startService(Main.class);
但是他们都没有开始服务,我该怎么办?