I would like to write an android app that interacts with USSD session menus
According to my research in Java, there is the possibility of using TelephonyManager to execute the USSD, read the response and use the accessibility service to enter programmatically in the dialog box inputs and interact with it. this
Except that I use React native, and I don't have a very good base in java to achieve my goals.
I would like if possible to have a java method which takes in parameter the USSD to be executed, as well as a string (or an array), of value to be completed automatically in each step of my USSD session which I would then expose as a module in my react native code
the code in javascript would look something like this:
const shorCodeString = "*144#";
const stepValuesString = "1*7*1*1225";
function interactWithUssd(shortCode, stepValues) {
const stepValuesArray = extractStep(stepValues); // [1,7,1225]
let step = 0;
executeUssd(shortCode).then((result) => {
while (step < stepValuesArray.length) {
if (stepValuesArray[step] !== undefined) {
whriteInput(stepValuesArray[step]);
send();
step += 1;
}
}
});
}