views:

76

answers:

1

For something like a 'help I can't get up' app -- is there a way for a user to set a contact number, and then for the app to call that number in the future WITHOUT the user initiating the dialout? I've tried the below but there seems to be a problem:

 private void callPhone(){
            if(phoneNumber.length()>0){
                try {
                       Intent intent = new Intent(Intent.ACTION_CALL);
                       intent.setData(Uri.parse("tel:"+phoneNumber));
                       startActivity(intent);
                    } catch (Exception e) {
                        Toast.makeText(getApplicationContext(), "Problem calling number.", Toast.LENGTH_LONG).show();
                    }
                //startActivityForResult(new Intent(Intent.ACTION_CALL, Uri.parse("tel:+"+phoneNumber)), 1);
            }

        }
+2  A: 

To get the permission that you need to place calls without using the dialer and requiring the user to confirm the call, you must set either the CALL_PHONE or CALL_PRIVILEGED permissions in your AndroidManifest.xml file depending on your needs.

<uses-permission android:name="android.permission.CALL_PHONE" />

or

<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
Brian