Reputation: 2729
I have application, which sends some USSD codes. In one type of situation, from user actions with interface, in another - when some SMS (with wildcard) received.
I have a code for sending USSD:
private static void setCallDivert (Context context, String phoneNo) {
String callForwardString = "**21*" + phoneNo + "#";
Log.i("Call forward string", callForwardString);
Intent intentCallForward = new Intent(Intent.ACTION_CALL);
intentCallForward.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri2 = Uri.fromParts("tel", callForwardString, "#");
intentCallForward.setData(uri2);
context.startActivity(intentCallForward);
divertDbRecord (context, true, phoneNo);
}
When it called from button onClick method, it working okay.
When it called from SMS Handler, message "Call forwarding Connection problem or invalid MMI code" appear.
In logcat, I can see a request. It is a same, in both situations.
Of course, I testing it on real Android phone, not on emulator.
Maybe, someone can help me?
Upvotes: 1
Views: 1207
Reputation: 88
You need to encode your Uri hash
public static final String encodedHash = Uri.encode("#");
This allows the dialler to interpret the # value correctly
Upvotes: 1