Android Question intent.getByteArrayExtra and intent.getIntExtra

moster67

Expert
Licensed User
Longtime User
I am converting a java android project and of course I want the code , whenever possible, to be written in B4A. So in this case, I am lifting out code which deals with Intents but which I am not sure how to write in B4X.

This is the method from the java-sources:
Java:
    private void sendCRTE(Intent intent) {
        byte[] content = intent.getByteArrayExtra("content");
        int target = intent.getIntExtra("target_id", 0x000001);
        int targetType = intent.getIntExtra("target_type", 0);

        app.sendmessage((short) targetType, target, content);
    }

translated into non-valid B4A code:
B4X:
private Sub sendSmsTxCRTE(myIntent As Intent)
    Dim content() As Byte = myIntent.GetExtra("content") 'I need getByteArrayExtra
    Dim target As Int = myIntent.GetExtra("target_id", 0x000001) 'I need getIntExtra - GetExtra does not permit 2 parameters
    Dim targetType As Int = myIntent.GetExtra("target_type", 0) ''I need getIntExtra - GetExtra does not permit 2 parameters
    app.sendmessage(targetType, target, content)
End Sub

So, the problem is how can I use the Intent methods getByteArrayExtra and getIntExtra in B4A? I guess I can wrap them but I wanted to remain within B4A as much as possible.
Can this be done with JavaObject? If yes, can someone show a snippet or link me to perhaps an existing example. I searched the forum but couldn't find anything.

Many thanks for your help.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top