Android Question big problem with StartActivityForResult with JavaObject

Status
Not open for further replies.
I just already wrote several posts for this problem and I still can't find a solution, I try again. The problem was that I can't get the result of the activity

B4A code::
Private Sub btnBluethootTest_Click
 
    Dim jo As JavaObject
    Try
        'Note#1: The class string for InitializeNewInstance is composed of
        '1) Package name: in this test case b4a.example (GetPackageName)
        '2) The name of the class module in B4A in lowercase. In this case the class module
        '   name is Test, but since B4A lowercases module names it becomes: test
        '3) The name of the class defined in the #if JAVA section (case sensitive): TestThis
        'Note#2: You could have a constructor declared. The call here would call one with
        ' no parameters
        Dim classstring As String = Utilita.GetPackageName & ".smartrft.ziwiIntegrator"
        Log("NewInstanceOf: " & classstring)
     
        Log(jo2.RunMethod("GetThisActivity",Null))
        jo.InitializeNewInstance(classstring,Array(jo2.RunMethod("GetThisActivity",Null)))
     
        jo.RunMethod("GetEVA_Stitch",Array(0,0,112,True))
     
        'Log(jo.RunMethod("getIntent",Null))
        intentSendTMP = jo.RunMethod("getIntent",Null)
        StartActivityForResult(intentSendTMP)
    Catch
        Log(LastException)
    End Try
 
End Sub


'Funzione che gestisce il risultato dell'activity
Sub ion_Event (MethodName As String, Args() As Object) As Object
    Args(0) = 38796'resultCode
    Args(1) = intentSendTMP'intent
    Try
        'Args(0) = 0x0000978c 'alias 38796
        Log("resultCode " & Args(0))
        'Args(1) = intentSendTMP
        Log("Intent "     & Args(1))
        jo2.RunMethod("ReturnResponseBluethooth",Array As Object(Args(0),Args(1)))
    Catch
        Log(LastException)
    End Try
    Return Null
End Sub

'Funzione che utilizza questo oggetto ion
Sub StartActivityForResult(i As Intent)
    Log("entra startactivityresult b4a " & i)
    Dim jo As JavaObject = GetBA
    ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
    jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub

'Ottiene l'istanza del Modulo B4A
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

#if java #end if:
public Activity GetThisActivity()
{
    return this;
}

//Inside Class ziwiIntegrator
//Metodo Costruttore 1 - Usato quando si lavora all'interno di un'Activity
    public ziwiIntegrator(Activity activity)
    {
        this.activity = activity;
        this.fragment = null;
        mContext=activity;
        InitData();
    }

 public final AlertDialog GetEVA_Stitch(int IrDaSecurity, int IrDaPassword, int boudRate, boolean resetEVACounter) {
        Intent intentScan = new Intent(Intent.ACTION_MAIN);
        Intent intentSend;
        intentScan.addCategory(ZIWI_PACKAGE);

        ApplicationInfo targetAppPackage = findTargetAppPackage(intentScan);
        if (targetAppPackage == null)
        {
            return showDownloadDialog();
        }
     
        intentSend = new Intent("sv.ziwi.external");
        intentSend.putExtra("ACTION", "GetEVA_Stitch" );
        intentSend.putExtra("KEY", "" );
        intentSend.putExtra("BOUDRATE", boudRate);
        intentSend.putExtra("IRDA_SECURITY", IrDaSecurity);
        intentSend.putExtra("IRDA_PASSWORD", IrDaPassword);
        intentSend.putExtra("CALLER_ID", getApplicationName(mContext));
        intentSend.putExtra("RESETEVACOUNTER",resetEVACounter);
     
        //intentSend.putExtra("ZIWIRESPONSE","TEST");
     
        //BA.Log("INTENT SEND " + intentSend);
        //BA.Log("REQUEST CODE " + REQUEST_CODE);
     
        setIntent(intentSend);
        setRequestCode(REQUEST_CODE);
     
        //startActivityForResult(intentSend , REQUEST_CODE);
        return null;
    }

public Intent getIntent()
    {
        BA.Log("FUNZIONE GET INTENT INTENT SEND " + intent_tmp + "" + intent_tmp.getStringExtra("ZIWIRESPONSE"));
        return intent_tmp;
    }
 
Status
Not open for further replies.
Top