Android Question StartActivityForResult , need help

Discussion in 'Android Questions' started by itgirl, Feb 2, 2015.

  1. itgirl

    itgirl Active Member Licensed User

    hello guys , im trying to open intent to get uri of selected image but im facing little problem ...To start the intent i, using

    Code:
    Dim i As Intent
            i.Initialize(
    "android.intent.action.GET_CONTENT""")
            i.SetType(
    "image/*")
            StartActivityForResult(i)
    and then


    Code:
    Sub ion_Event (MethodName As String, Args() As Object) As Object
    If Args(0) = -1 Then 'resultCode = RESULT_OK
         Dim i As Intent = Args(1)
         
    Dim jo As JavaObject = i
         
    Dim Uri As String = jo.RunMethod("getParcelableExtra", _
           
    Array As Object("android.intent.extra.?????????")) ' HERE IS THE PROBLEM WHICH CODE SHOULD I USE HERE
         Log(Uri)
         
    Log(i)

       
    End If
       
    Return Null
    End Sub
    Sub StartActivityForResult(i As Intent)
      
    Dim jo As JavaObject = GetBA
       ion = jo.CreateEvent(
    "anywheresoftware.b4a.IOnActivityResult""ion"Null)
      jo.RunMethod(
    "startActivityForResult"Array As Object(ion, i))
    End Sub
    Sub GetBA As Object
      
    Dim jo As JavaObject
      
    Dim cls As String = Me
      cls = cls.SubString(
    "class ".Length)
      jo.InitializeStatic(cls)
      
    Return jo.GetField("processBA")
    End Sub


    any one can help me out here ?
     
    Last edited: Feb 2, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    Why don't you use ContentChooser?
     
  3. itgirl

    itgirl Active Member Licensed User

    i would rather not to use ContentChooser it's better to stick to the native Gallery method . is it hard to get it the way im trying to do it ? i found a tut for you Erel HERE but it was for a ring tone it works great but you used
    Code:
    android.intent.extra.ringtone.PICKED_URI
    so i was wondering what should i use to get the uri of picked image?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    What is the output of Log(i.ExtrasToString)?
     
  5. itgirl

    itgirl Active Member Licensed User

    that's what im facing here when i do
    Code:
    log(i)
    i get
    Code:
    (IntentIntent { dat=content://media/external/images/media/1 }
    but when i do
    Code:
    log(i.ExtrasToString)
    i get
    no extras
    :(
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Now that I go over your code I don't see any reason not to use ContentChooser. You will get the exact same result. ContentChooser creates the same intent that you are creating.
     
  7. itgirl

    itgirl Active Member Licensed User

    Ok Erel thanks for the advice , i think i will do just like you said and i will use ContentChooser , thanks for the replies you ROCK
     
Loading...
  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