Pattabi Raman
Pattabi Raman

Reputation: 5854

Android: How to launch call intent using google voice?

How to launch specific intent (such as call) using google voice? How to pass phone number using intent? Following code launches google voice but what value to be passed for making call using google voice as intent extras?

final Intent intent = new Intent();
intent.setComponent(new ComponentName("com.google.android.apps.googlevoice", "com.google.android.apps.googlevoice.activity.conversationlist.ConversationListActivity"));

intent.putExtra("label", "<phone number>");

startActivity(intent);

Here what should i put in label to start the intent that launches a call using google voice? Any help is appreciated... Thanks in Advance...

Upvotes: 1

Views: 909

Answers (2)

StoneLam
StoneLam

Reputation: 400

What @JoxTraex said makes sense. However some clients need funny features like this, so we have no way but to implement this:

try {
        Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:" + mobile));
        intent.setPackage("com.google.android.apps.googlevoice");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    } catch (ActivityNotFoundException anfe) {
        GMHintManager.getInstance().showError(context, "Google Voice not installed");
    }

Yes, you should try-catch ActivityNotFoundException.

Upvotes: 1

jtt
jtt

Reputation: 13541

NEVER target applications directly like that UNLESS it is in your package. You should be using the Intent filter to catch that particular application. Sometimes you have to target an application like this, but this brings up the risk of change in package name errors.

To handle your particular application, you need to look at how information is being passed into Google voice. this will give you insight and how to target it WITHOUT targeting the exact package name.

Upvotes: 1

Related Questions