Android Question Install intent with result

Rusty

Well-Known Member
Licensed User
Longtime User
I'm trying to install a downloaded .apk file using a StartActivityForResult.
Code:
B4X:
Sub InstallPackage
    Dim i As Intent
    i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(FileFolder, FileName))
    i.SetType("application/vnd.android.package-archive")
    StartActivityForResult(i)
End Sub

Sub ion_Event (MethodName As String, Args() As Object) As Object
    LogColor("                INSTALL result " & Args(0), Colors.blue)
    '    LastActivity = "Main"
    If Args.Length > 0 Then
       
    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
The above code is not working and I've gotten to the point I'm not seeing the "forest for the trees".
Can someone please advise, I'm sure it is something simple, only I can't see it
thanks in advance,
Rusty
 
Top