0

My program is working absolutely fine from android 2.1 to android 2.3 But its not working on higher version of android. It does not give any exception when the app is executed on a higher version than 2.3. When run on 2.3 or lower version the number is correctly dialed and imei or other query is executed properly but when the app is run on higher version only dialpad with the code opens but the number/code is not dialed I have used in my manifest file

<uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="18" />

And my MainActivity Class

public class Motorola extends Activity implements OnClickListener{
    TextView tvm1,tvm2,tvm3;
    Intent myIntent;
    String m=Uri.encode("#");
    String str;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.motorola);
        tvm1=(TextView) findViewById(R.id.tvmo1);
        tvm2=(TextView) findViewById(R.id.tvmo3);
        tvm3=(TextView) findViewById(R.id.tvmo2);
        AdView adv3=(AdView) findViewById(R.id.ad4);
        adv3.loadAd(new AdRequest());
        tvm1.setOnClickListener(this);
        tvm2.setOnClickListener(this);
        tvm3.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        /* *#06#:DISPLSYS IMEI NUMBER.
   *#*#4636#*#*:DISPLAY INFORMATION ABOUT PHONE, BATTERY AND USAGE STATISTICS.
   ##7764726:MOTOROLA DROID HIDDEN SERVICE MENU. THE DEFAULT SPC PASSWORD IS SIX ZEROES (000000).*/
        switch(v.getId())
        {
        case R.id.tvmo1:
            str="*"+m+"06"+m;
            myIntent=new Intent(Intent.ACTION_DIAL);
            myIntent.setData(Uri.parse("tel:"+str));
            startActivityForResult(myIntent,1);
            break;          

        case R.id.tvmo2:
            str="*"+m+"*"+m+"4636"+m+"*"+m+"*";
            myIntent=new Intent(Intent.ACTION_DIAL);
            myIntent.setData(Uri.parse("tel:"+str));
            startActivityForResult(myIntent,1);
            break;          
        case R.id.tvmo3:

            str=m+m+7764726;
            myIntent=new Intent(Intent.ACTION_DIAL);
            myIntent.setData(Uri.parse("tel:"+str));
            startActivityForResult(myIntent,1);
            break;
        }
    }
}
Michael Yaworski
  • 13,410
  • 19
  • 69
  • 97
nitin34
  • 21
  • 4
  • 1
    This is most likely a security feature to prevent apps from dialing codes that could harm the phone... I unfortunately wasn't able to find anything to confirm this though – Ryan S Jan 06 '14 at 00:53
  • Thanks for your reply Sir,can you suggest any solution for this problem? – nitin34 Jan 06 '14 at 12:30

2 Answers2

0

For some codes, you can try using Intent.ACTION_CALL instead of Intent.ACTION_DIAL

But for most codes Im afraid you wont be able of doing that.

You can take a look at this answer

... in the beginning, it was possible to directly call USSD codes from an app (using the intent Intent.ACTION_DIAL) [...] But that was actually considered a vulnerability of the system, since somebody could write malicious software, or even more, insert malicious code in a website that could even wipe your phone or block the sim card[...] At this point it will be hard to find any device still vulnerable.

Go to the answer to find out more

Community
  • 1
  • 1
Carlos Robles
  • 10,828
  • 3
  • 41
  • 60
0

You shouldn't be using the dialer for these tasks. Instead, use the appropriate Android APIs to get this information. Here are two questions to get you started quickly:

For more details, see the TelephonyManager reference documentation and the Android training article Monitoring the Battery Level and Charging State.

Community
  • 1
  • 1
quietmint
  • 13,885
  • 6
  • 48
  • 73