尝试以编程方式捕获屏幕时的java空指针
这是我的密码
// create bitmap screen capture
Bitmap bitmap;
View v1 = (View)findViewById(R.id.text);
View rootV = v1.getRootView();
rootV.setDrawingCacheEnabled(true);
bitmap = rootV.getDrawingCache();
rootV.setDrawingCacheEnabled(false);
空指针出现在bitmap = rootV.getDrawingCache();
上,R.id.text
是布局中的文本视图
# 1 楼答案
我在这里找到了答案。这是因为我在onCreate()中调用了该方法
Screen capture inside the method onCreate not working in android