I have an app that make USSD calls, but after all USSD calls i got a dialog with the result to the user.

I know that is possible to dismiss this dialog because the "USSD Checker" app do this, they get the response from USSD without showing the user dialog.

Has the function displayMMIComplete that after complete the Ussd call, show a TYPE_SYSTEM_DIALOG. In the PhoneUtils.java they use the dialog like this:

AlertDialog newDialog = new AlertDialog.Builder(context)

.setMessage(text)

.setPositiveButton(R.string.ok, null)

.setCancelable(true)

.create();

newDialog.getWindow().setType(

WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);

newDialog.getWindow().addFlags(

WindowManager.LayoutParams.FLAG_DIM_BEHIND);

newDialog.show();

Then i can't just send some flag to dismiss it. And I can't use that import its a system class.

And when I do X consecutive calls appears X dialogs to the user close, and my app will need to do consecutive calls, there is anyway to programmatically close this System dialog?

解决方案

I found an Answer to my question if you're trying to use USSD Calls you can disable the result text

In a russian blog there is a post that show how you can connect to the phoneutils service of android, then control the texts from USSD (CALL and RESULT). He show a sample using a interface (IExtentedendNetworkService ) that binds on phone utils just on the android OS start and if there was not any other app trying to do the same (Because just one service can be bound and maybe will be your or not, I don't know the rule that Android OS uses to choose).

In the function "CharSequence getUserMessage(CharSequence text);" if you return null the result dialog will not appear.

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐