質問

Am developing functionality in which i wanted to Intent.ACTION_DIAL. Below is the code which i have tried so far.

    Intent callIntent = new Intent(Intent.ACTION_DIAL);
    String str = "tel:xxxxxxxxxx";                             callIntent.setData(Uri.parse(str));
                                    context.startActivity(callIntent);

However facing below two problems

1) if i tried to retrieve the imei number using "tel:#06#" then it will open the device dialer with '' only. "#06#" is not appearing there.

2) It asks the user to press call button. I dont want user to press the call button. is there any API which will allow me to directly execute "tel"*#06# kind of code from application itself.

EDITED:

I have tried below answer. its invoking dialer with "*#06#" but not showing the IMEI number of the device. if i press the same from device dialer and it showing IMEI number instantly. All i want is to show the IMEI kind of codes from Application.

役に立ちましたか?

解決

        Intent callIntent = new Intent(Intent.ACTION_CALL);  
        String encodedHash = Uri.encode("#");  
        String ussd = encodedHash + "06" + encodedHash;  
        startActivityForResult(new Intent("android.intent.action.CALL",  
        Uri.parse("tel:" + ussd)), 1);  

and give this permission in android menifest

<uses-permission android:name="android.permission.CALL_PHONE" />
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top