crodie
crodie

Reputation: 112

Phone call intent

I'm having a problem with this phonecall intent.

my code:

public void onClick(View v) {
    try {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:+32123456789"));
        startActivity(callIntent);
    } catch (ActivityNotFoundException e) {
         e.printStackTrace();
    }
}

with permission:

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

So, when i hit the button that triggers the event, my phone is ready to make to call. Now when i hit the back button, he goes back to my app AND he makes a phone call in the background.

Thanks in advance!

Upvotes: 1

Views: 1821

Answers (2)

HimanshuR
HimanshuR

Reputation: 1438

Use permission in manifest.xml file as some intents need permission to call. As you can see on this link, first file is manifest.xml

Upvotes: 2

Safime
Safime

Reputation: 201

Try this:

        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + phoneNumber));
        startActivity(callIntent);

Edit: Sorry, I didn't analyzed the question well.. It's the same..

Upvotes: 0

Related Questions