设置壁纸应该这么难:(
好吧,我认为它抛出了异常。不幸的是我没有收到错误。 它可以加载到模拟器和我的手机上,但无法执行。它只是说:“应用程序 MyApp(进程 com.myapp)已意外停止。请重试。”然后是强制关闭按钮。 :(
再次这是我的代码:
public void onClick(DialogInterface dialog, int id) {
try {
MyActivity.this.setWallpaper(mContext.getDrawingCache());
finish();
} catch (IOException e) {
e.printStackTrace();
}
}
在我自己的研究中,我看到有人从 getDrawingCache 获取位图并将其转换为位图?但是 view.getDrawingCache 上的文档说它已经是位图,并且 setWallpaper 应该设置一个位图... 我在这里没有主意了。
ok i think it's throwing an exception. unfortunately i am not getting an error.
it loads on the emulator and my phone but won't perform. it just says, "The application MyApp (process com.myapp) has stopped unexpectedly. Please try again." and then a ForceClose button. :(
once again here is my code:
public void onClick(DialogInterface dialog, int id) {
try {
MyActivity.this.setWallpaper(mContext.getDrawingCache());
finish();
} catch (IOException e) {
e.printStackTrace();
}
}
on my own research i saw someone getting the bit map from getDrawingCache and converting it to a bitmap? but the documentation on view.getDrawingCache says it is already a bitmap, and setWallpaper is supposed to set a bitmap...
i am out of ideas here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
什么是 mContext? getDrawingCache() 是 View 类的一个方法,只有在第一次调用 setDrawingCacheEnabled(true) 或调用 buildDrawingCache() 时才会返回有效的 Bitmap。您还必须确保视图经过布局传递,并且其宽度和高度 > > 0。
What is mContext? getDrawingCache() is a method of the View class, and will only return a valid Bitmap if you first call setDrawingCacheEnabled(true) or if you call buildDrawingCache(). You also must make sure that the View went through a layout pass and that its width and height are > 0.