Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Dim ion As Object
Dim pm As PackageManager
Dim dt As DynamicToast
End Sub
Sub Globals
Dim versionepackage As String
Private btn_irda As Button
Dim rp As RuntimePermissions
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("lay_ziwi")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btn_irda_Click
'xui.MsgboxAsync("Hello world!", "B4X")
Dim i As Intent
Dim jo As JavaObject
Dim ctx As JavaObject
ctx = jo.InitializeContext
i.Initialize(i.ACTION_MAIN,"")
i.SetComponent("sv.ziwi/sv.ziwi.ExternalCall")
i.PutExtra("ACTION", "GetEVA_Stitch")
i.PutExtra("KEY", "" )
i.PutExtra("BOUDRATE", 96)
i.PutExtra("IRDA_SECURITY", 0000)
Log("SECURITYIRDA:")
'Log(securityirda)
i.PutExtra("IRDA_PASSWORD",0000)
'Log("PASSWORD: " & password)
i.PutExtra("CALLER_ID",jo.RunMethod("getApplicationName",Array(ctx)))
'i.PutExtra("RESETEVACOUNTER",True)
StartActivityForResult(i)
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 ion_Event (MethodName As String, Args() As Object) As Object
Log(MethodName)
Log(Args)
Dim risp As String
If Args(0) = 0 Then 'resultCode = RESULT_OK
Dim i As Intent = Args(1)
If(i.IsInitialized = False) Then
Log("non è un INTENT")
Return Null
End If
risp = i.GetExtra("ZIWIRESPONSE")
Log("RISPOSTA: ")
Else
Dim i As Intent = Args(1)
End If
Return Null
End Sub
Sub GetContext As JavaObject
Return GetBA.GetField("context")
End Sub
Sub GetBA As JavaObject
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetFieldJO("processBA")
End Sub
#if java
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.util.Log;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public String getApplicationName(Context context) {
ApplicationInfo applicationInfo = context.getApplicationInfo();
int stringId = applicationInfo.labelRes;
return stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : context.getString(stringId);
}
#End If