0
每当我点击一次takescreenshot按钮它卡住,并不断采取截图。屏幕截图按住屏幕截图时卡住
停止按钮
这个按钮的功能是停止线程,并从截屏停止代码。
Thread th = new Thread(new Runnable() {
@Override
public void run() {
StopThread.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
thread.interrupt();
check=false;
//textView.setText(TotalShots);
}
});
}
});
th.start();
抓图按钮
这个按钮的功能是启动线程,并开始采取截图。
public void screenShot(View view) throws IOException {
thread = new Thread(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (!Thread.interrupted()){
while (check)
{
captureScreenShot = (Button) findViewById(R.id.capture_screen_shot);
c = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
name = simpleDateFormat.format(c.getTime());
mbitmap = getBitmapOFRootView(captureScreenShot);
imageView.setImageBitmap(mbitmap);
try {
createImage(mbitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
});
}
});
thread.start();
}
点击查看UI of App
我想要代码继续截图,直到按下停止按钮。 –
仍然存在问题。它不允许我按停止按钮。 –