Android Question Using Photos from the Phone

Discussion in 'Android Questions' started by Shadow&Max, Feb 3, 2014.

  1. hibrid0

    hibrid0 Active Member Licensed User

    I try your code, And I dont use SQL in my App, I add SQL Library and say "java.lang.RuntimeException: Object should first be initialized (Cursor)."

  2. Erel

    Erel Administrator Staff Member Licensed User

    This means that the file path is not available. Note that in most cases you do not need this path to work with the selected image.
  3. Marco Nissen

    Marco Nissen Active Member Licensed User

    Well, it seems as if the file path is a security issue for the latest update of Android. Instead, you should use the input stream via content resolver / openinputstream .. small snippet:

    Sub GetStreamFromContentResult(UriString As StringAs InputStream
    Dim r As Reflector
    Dim Uri As Object
    Dim iStream As InputStream
    Uri = r.RunStaticMethod("""parse"Array As Object(UriString), Array As String("java.lang.String"))
        r.Target = r.GetContext
        r.Target = r.RunMethod(
        iStream = r.RunMethod4( 
    "openInputStream"Array As Object(Uri), Array As String(""))
    Return iStream
    End Sub
    With this, you can easily receive e.g. a PDF

    Dim theTitle As String =getTitleFromContent(ShareString)  ' the approach above using _display_name
                            Dim thePath As String = ah.getTemporaryDirectory ' my way to obtain a writeable path
                            Dim jo As JavaObject
    Dim Inp As InputStream  = GetStreamFromContentResult(ShareString)
    Dim Out As OutputStream = File.OpenOutput(thePath, theTitle, False)
    File.copy2(Inp, Out)
                                                    receivedPDF = thePath & 
    "/" & theTitle
    Log(":: issue " & LastException)
    End Try
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice