Android Question PLS help me with JavaClass Implementation With OnActivityResult

pls help me about this implementation....
I'll keep it simple and try to be clear. I have 2 Class in .java (ziwiIntegratror and ziwiResponse) and these java files need to implement 'com.google.code.gson:gson:2.8.6' (DONE).
I put exactly these java files between the tags "#if Java #End If" and also I personally modified some parts of the code where I used the lambda function and SO FAR ALL CORRECTLY.....so...I created the function where I recall what I need:

public void TestBluetooth()
{
Activity activity = this;

//Istanzio l'oggetto ziwiIntegrator lanciandolo con il primo metodo costruttore
ziwiIntegrator ziwi = new ziwiIntegrator(activity);
//Chiamo adesso la funzione GetEvaStitch
ziwi.GetEVA_Stitch(0,0,ziwiIntegrator.IRDABOUD_AUTO,true);
}

and in B4A i create the JavaObject and:

Private Sub btnBluethootTest_Click
jo2.RunMethod("TestBluetooth",Null)
End Sub

AND WORK, successfully opens the intent of this ziwi and I can detect
SO THE PROBLEM IS THIS:

in the documentation of these java files i have this function OnActivityResult

@override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
String res="";
ziwiResponse zr=new ziwiResponse();
if (requestCode==0x0000978c){
if (data!=null && data.getStringExtra("ZIWIRESPONSE")!=null){
res=data.getStringExtra("ZIWIRESPONSE");
zr=zr.GetResponse(res);
Log.d("jj","" + res);
Log.d("jj","" + zr.getEVA());
}
}
}


and this obviously allows me to find the result of the Intent opened before and I'm not able to make it work at all
 

walterf25

Expert
Licensed User
Longtime User
pls help me about this implementation....
I'll keep it simple and try to be clear. I have 2 Class in .java (ziwiIntegratror and ziwiResponse) and these java files need to implement 'com.google.code.gson:gson:2.8.6' (DONE).
I put exactly these java files between the tags "#if Java #End If" and also I personally modified some parts of the code where I used the lambda function and SO FAR ALL CORRECTLY.....so...I created the function where I recall what I need:

public void TestBluetooth()
{
Activity activity = this;

//Istanzio l'oggetto ziwiIntegrator lanciandolo con il primo metodo costruttore
ziwiIntegrator ziwi = new ziwiIntegrator(activity);
//Chiamo adesso la funzione GetEvaStitch
ziwi.GetEVA_Stitch(0,0,ziwiIntegrator.IRDABOUD_AUTO,true);
}

and in B4A i create the JavaObject and:

Private Sub btnBluethootTest_Click
jo2.RunMethod("TestBluetooth",Null)
End Sub

AND WORK, successfully opens the intent of this ziwi and I can detect
SO THE PROBLEM IS THIS:

in the documentation of these java files i have this function OnActivityResult

@override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
String res="";
ziwiResponse zr=new ziwiResponse();
if (requestCode==0x0000978c){
if (data!=null && data.getStringExtra("ZIWIRESPONSE")!=null){
res=data.getStringExtra("ZIWIRESPONSE");
zr=zr.GetResponse(res);
Log.d("jj","" + res);
Log.d("jj","" + zr.getEVA());
}
}
}


and this obviously allows me to find the result of the Intent opened before and I'm not able to make it work at all
there should be plenty of examples, you can start here.

Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I think I've read all about these Erel examples and applied them too, I've been getting lost in this problem at work for about 2 weeks
Show us what you have done so far, are you getting any errors, what is the problem exactly?
 
Upvote 0
Show us what you have done so far, are you getting any errors, what is the problem exactly?
Sure, so, the following java code as I wrote above is all correct, the final result is to open an external intent given by this "ziwiintegrator" library which allows me to detect EVA-DTS data.
the problem is that being an external intent, the latter must return a JSON given as a result and to do so I need an onActivityResult function. I saw that it is not possible to write it of course on the #if java #end if tags and therefore I have to arrange it with B4a.
So, as it should be, I instantiate the ziwi object from the ziwiIntegrator class which executes its GetEVA_Stitch function which in turn starts this intent, to work everything with the OnActivityResult function I take the given result. How do I do this on B4A via the Erel gudia you linked to me?

so pls...in attach i put the documentation
 

Attachments

  • Integrazione rev 1.2.pdf
    152.6 KB · Views: 161
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
the .pdf documentation you posted does not tell us what you have done so far.

where is the code to StartActivityForResult()? show it. no explanation necessary; just show how you prepare and run StartActivityForResult().
show your code which implements @Erel's example. no explanation necessary; just show what you have done so far with the example.
(note: @Erel's example works very well. it is clear, simple and very well written. i use it all the time without a problem).

it would be helpful if you would show the code within "</>" tags, as previously requested. tap the "</>" icon above and put the code in the dialog.
 
Last edited:
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Sure, so, the following java code as I wrote above is all correct, the final result is to open an external intent given by this "ziwiintegrator" library which allows me to detect EVA-DTS data.
the problem is that being an external intent, the latter must return a JSON given as a result and to do so I need an onActivityResult function. I saw that it is not possible to write it of course on the #if java #end if tags and therefore I have to arrange it with B4a.
So, as it should be, I instantiate the ziwi object from the ziwiIntegrator class which executes its GetEVA_Stitch function which in turn starts this intent, to work everything with the OnActivityResult function I take the given result. How do I do this on B4A via the Erel gudia you linked to me?

so pls...in attach i put the documentation
Can you share you project, I don't have the library.
 
Upvote 0
Top