无法解析IntelliJ中的符号BitmapFactory.decodeResource

Sro*_*iej 3 android intellij-idea bitmapfactory

我尝试在我的Activity中使用类BitmapFactory中的方法decodeResource,如下所示:

Bitmap image = new BitmapFactory.decodeResource(getResources(),R.drawable.my_image);
Run Code Online (Sandbox Code Playgroud)

我做了所有必要的导入,IntelliJ甚至为我填写方法,因为我输入它但是当我尝试编译它时给了我错误:

java: cannot find symbol

symbol:   class decodeResource 

location: class android.graphics.BitmapFactory
Run Code Online (Sandbox Code Playgroud)

Pra*_*ani 12

删除new,因为decodeResource是静态方法,

像这样使用

Bitmap image = BitmapFactory.decodeResource(getResources(),R.drawable.my_image);
Run Code Online (Sandbox Code Playgroud)