Unsolved How to execute USSD?
-
Hello, I would like to know how to execute USSD codes from a qml file, for example:
Button { text: "Execute USSD" onClicked: executeUSSD(ussdCode) }
I need to know how to implement the
executeUSSD ()
function -
@Blaster if by USSD you mean Unstructured Supplementary Service Data, I guess you may want to get some library that provides or helps you implementing that functionality. Maybe this example is a good starting point.
-
I just want to run USSD codes compatible with GSM, for example *123#, from android
-
Hi,
Do you mean something like described here ?
-
Yes, I'll try it and then I'll tell you if it worked for me. Thank you
-
@SGaist I am trying to adapt the code shown in the tutorial that you put, but there is no way to find how to encode the #
-
Do you mean
Uri.encode("#")
doesn't do the job ? -
Does anyone know how to do these in Qt?
private void dailNumber(String code) { String ussdCode = "*" + code + Uri.encode("#"); startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCode))); }
I apologize for that, but now I'm learning
-
Take a look at the QtAndroidExtras module.
It allows you to interface easily with Java code.
-
This post is deleted! -
Well, I have already implemented the function in a java class. But I can not find the way to call it ... the problem is with startActivity (intent) the function in java is:
public void dailNumber(String code) { String ussdCode = "*" + code + Uri.encode("#"); startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCode))); }
While the method with which we call it is:
void CallDirectly::runUSSD(QString code) { QAndroidJniObject ussdCode = QAndroidJniObject::fromString(code); QAndroidJniObject::callStaticObjectMethod("cu/myapp/javaclases", "dialNumber", "(Ljav/lang/String;)V", ussdCode.object<jstring>()); }
-
What is exactly your problem ?
-
@SGaist My problem is that I can not call the dialNumber method, it does not run. Is there something wrong with my code?