1

我有一个覆盖onKeyDown. 这是方法:

    @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        // my stuff     
       }
}

现在,如果我尝试在我的应用程序中截屏,长按截屏所需的按钮似乎不起作用。有没有不那么痛苦的方法可以再次截图?

PS对不起我的英语

4

3 回答 3

1
  @Override
  public boolean onKeyDown( int keyCode, KeyEvent event ) {
    if( keyCode == KeyEvent.KEYCODE_BACK ) {
      event.startTracking();
      return true; 
    }
    return super.onKeyDown( keyCode, event );
  }

  @Override
  public boolean onKeyUp( int keyCode, KeyEvent event ) {
    if( keyCode == KeyEvent.KEYCODE_BACK ) {
      //Your stuff. (Handle what you want on short press).      
      return true; 
    }

    return super.onKeyUp( keyCode, event );
  }

  @Override
  public boolean onKeyLongPress( int keyCode, KeyEvent event ) {
    if( keyCode == KeyEvent.KEYCODE_BACK ) {
      //Handle what you want in long press.
      return true;
    }
    return super.onKeyLongPress( keyCode, event );
  }
于 2013-06-13T10:55:13.500 回答
0

尝试这个

Layout.setDrawingCacheEnabled(true); //Root layout of your APP
Bitmap bmp=Layout.getDrawingCache(); //Screen shot bitmap
于 2013-06-13T10:20:27.293 回答
0

在这种情况下使用 Eclipse- DDMS View 截屏。这很容易。

于 2013-06-13T10:38:18.910 回答