I'm trying to upload an image to my album VC. I use this code , for a long time I can not figure it out, so I try different ways. In each of them I manage to pass authorization, and then: in the first method, nothing happens, in the second, the exception specified below is dropped and the application is closed, in the third, similarly to the second. How to fix the error?
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=10485, result=-1, data=null} to activity {com.example.molodec.vktest/com.example.molodec.vktest.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference File photo = new File("android.jpg"); Первый способ final Bitmap photo = getPhoto(); Второй способ BitmapFactory.decodeStream(getAssets().open("android.jpg")); Третий способ