Android Question Crash while loading?

Spright

Active Member
I got a problem while loading a pixmap using a user requester. I save it inside local memory for later conversion into pixmap, and the code works in isolation but not with inside my game that uses.. the admob, starter and b4pages setup? One of these things must be trigger this and it only appens on one of my devices (a mid range, the code works on both 4.4.4 an on 9.0 for instance but not on 7.0). Any ideas what it could be becuase this is my carefully constructed base and I can't throw it away.

B4X:
' The ERRORMSG you would get on an Samsung A3 with 7.0
' Other devices from 4.4.4 to 9.0 works fine.

' All devices works fine when not using with Starter, BX4MainPage or Adshelper or somethint else disturbing? That's whay it seem to be doing but I have no idea how to go from here to debug as I need all of these in my project and cannot delete.

#IF THEN
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
success load
main_loadchooser_result (java line: 376)
java.io.FileNotFoundException: No such file or directory
    at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:144)
    at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:692)
    at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1151)
    at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:988)
    at android.content.ContentResolver.openInputStream(ContentResolver.java:708)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:212)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:516)
    at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1376)
    at b4a.example.main._loadchooser_result(main.java:376)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.phone.Phone$ContentChooser$1.ResultArrived(Phone.java:906)
    at anywheresoftware.b4a.BA$4.run(BA.java:593)
    at anywheresoftware.b4a.BA.setActivityPaused(BA.java:467)
    at b4a.example.main$ResumeMessage.run(main.java:313)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
#End If

' DEMO :  Load pixmap from using filerequester
 
#Region Init
    #MultiDex: True
    #AdditionalJar: com.google.android.ump:user-messaging-platform
    #Region Project Attributes
        #FullScreen: True
        #IncludeTitle: False
        #ApplicationLabel: Demo
        #VersionCode: 1
        #VersionName:
        #SupportedOrientations: Portrait
          #CanInstallToExternalStorage: False   
    #End Region
#End Region

#Region  Project Attributes
    #ApplicationLabel: Load
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
    Dim loadChooser As ContentChooser
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    loadChooser.Initialize("loadChooser")
    loadChooser.Show("image/*", "Choose image") ' Chooser.Show("audio/*", "Choose audio file")
End Sub
 
' PART OF LOADER(PART 3)
Sub loadChooser_Result (Success As Boolean, Dir As String, FileName As String)
    If Success = True Then
    
        Log("success load")
        If File.Exists(Dir, FileName) Then Log("EXISTS")
        
        Dim image As Bitmap
        image = LoadBitmap(Dir, FileName)

        Log(SaveBitmapAsPNG(image,"a.png"))
        If File.Exists(File.DirInternal, "a.png") Then Log("EXISTS")

        'If File.Exists(File.DirInternal, "temp.png") Then
        '    File.Delete(File.DirInternal, "temp.png")
        'End If

    Else
        ToastMessageShow("ERROR LOADING!", True)
    End If
End Sub

Sub SaveBitmapAsPNG(bitmap As Bitmap, fileName As String) As Boolean
    Try
        Dim out As OutputStream = File.OpenOutput(File.DirInternal, fileName, False)
        bitmap.WriteToStream(out, 100, "PNG")
        out.Close
        Return True
    Catch
        Return False
    End Try
End Sub
 

Attachments

  • demo.zip
    12.7 KB · Views: 64
Top