如何使用onClick在startService()和stopService()之间切换?

时间:2011-04-26 14:29:04

标签: java android surfaceview

如何在Surfaceview上的这两个意图之间切换,并在录制视频时创建在开始/暂停期间在youtube中看到的那种图形效果?

- > stopService(new Intent(getApplicationContext(),ServiceRecording.class)); - > startService(new Intent(getApplicationContext(),ServiceRecording.class);

public void onClick(View v)
            {

            }

1 个答案:

答案 0 :(得分:1)

有什么理由说明以下想法不起作用?

if (serviceRunning) {
  serviceRunning = false;
  stopService(...);
} else {
  serviceRunning = true;
  startService(...);
}