Example usage for android.content Intent ACTION_DIAL

List of usage examples for android.content Intent ACTION_DIAL

Introduction

In this page you can find the example usage for android.content Intent ACTION_DIAL.

Prototype

String ACTION_DIAL

To view the source code for android.content Intent ACTION_DIAL.

Click Source Link

Document

Activity Action: Dial a number as specified by the data.

Usage

From source file:org.kontalk.util.SystemUtils.java

public static void dial(Context context, CharSequence phone) {
    try {//w w w  .j  a  v  a 2  s.c  o m
        context.startActivity(externalIntent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone)));
    } catch (ActivityNotFoundException e) {
        Toast.makeText(context, R.string.chooser_error_no_dialer, Toast.LENGTH_LONG).show();
    }
}

From source file:com.denel.facepatrol.MainActivity.java

public void ContactPhone(View view) {
    Intent phoneIntent = new Intent(Intent.ACTION_DIAL);
    phoneIntent.setData(Uri.parse("tel:" + contact_phone));
    phoneIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    startActivity(Intent.createChooser(phoneIntent, "Phone Number"));
    //finish();//www .j a  v  a2s .  co m
}

From source file:com.oscarsalguero.dialer.MainActivity.java

/**
 * Dials a phone number using the ACTION_DIAL intent (does not require permission).
 *///from  w  ww  .j  a  va 2s.c  o m
private void dialPhone() {
    try {
        String phoneNumber = textViewDisplay.getText().toString();
        Intent dialIntent = new Intent(Intent.ACTION_DIAL);
        dialIntent.setData(Uri.parse(URI_PREFIX_TEL + Uri.encode(phoneNumber)));
        dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(dialIntent);
        logPhoneNumber(phoneNumber);
    } catch (Exception e) {
        Log.e(LOG_TAG, "An exception occurred trying to execute the DIAL intent.", e);
    }
}

From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java

private void processUrl(final String url) {
    String trimmedLowerCaseUrl = url.trim().toLowerCase(Locale.US);
    if (trimmedLowerCaseUrl.startsWith(URL_ROGERTHAT_PREFIX)) {
        if (url.contains("?")) {
            processInvitation(url);//from   w  w  w. ja  v a2 s.  co m
        } else {
            processEmailHash(url.substring(URL_ROGERTHAT_PREFIX.length()));
        }

    } else if (trimmedLowerCaseUrl.startsWith(URL_ROGERTHAT_SID_PREFIX)) {
        Matcher match = RegexPatterns.SERVICE_INTERACT_URL.matcher(url);
        match.matches();
        String emailHash = match.group(1);
        String sid = match.group(2);
        getServiceActionInfo(emailHash, sid);

    } else if (trimmedLowerCaseUrl.startsWith(SHORT_HTTPS_URL_PREFIX)) {
        mScanCommunication = new ScanCommunication(mService);
        mScanCommunication.resolveUrl(url);

    } else if (trimmedLowerCaseUrl.startsWith("http://") || trimmedLowerCaseUrl.startsWith("https://")) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        scannedUnknownQR(getString(R.string.qr_open_url, TextUtils.trimString(url, 100, true)), intent);

    } else if (trimmedLowerCaseUrl.startsWith("tel:")) {
        String number = url.substring(4);
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + number));
        scannedUnknownQR(getString(R.string.qr_call_tel, number), intent);

    } else {
        L.d("Cannot process url " + url);
        UIUtils.showLongToast(this, getResources().getString(R.string.unrecognized_scan_result));
        finish();
    }
}

From source file:spit.matrix2017.Activities.EventDetails.java

private void setContacts(final String name1, final String number1, final String name2, final String number2) {
    TextView contactTextViewOne = (TextView) findViewById(R.id.contact_name_one);
    TextView contactTextViewTwo = (TextView) findViewById(R.id.contact_name_two);

    ImageButton callOne = (ImageButton) findViewById(R.id.call_contact_person_one);
    ImageButton saveOne = (ImageButton) findViewById(R.id.save_contact_person_one);
    ImageButton callTwo = (ImageButton) findViewById(R.id.call_contact_person_two);
    ImageButton saveTwo = (ImageButton) findViewById(R.id.save_contact_person_two);

    assert contactTextViewOne != null;
    contactTextViewOne.setText(name1 + "\n" + number1);
    assert contactTextViewTwo != null;
    contactTextViewTwo.setText(name2 + "\n" + number2);

    View.OnClickListener callOnClickListener = new View.OnClickListener() {
        @Override//from w w w  . ja v a 2s . c o  m
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_DIAL);
            switch (v.getId()) {
            case R.id.call_contact_person_one:
                intent.setData(Uri.parse("tel:" + number1));
                break;
            case R.id.call_contact_person_two:
                intent.setData(Uri.parse("tel:" + number2));
                break;
            }
            startActivity(intent);
        }
    };

    View.OnClickListener saveOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_INSERT, ContactsContract.Contacts.CONTENT_URI);
            switch (v.getId()) {
            case android.R.id.home:
                EventDetails.super.onBackPressed();
                break;
            case R.id.save_contact_person_one:
                intent.putExtra(ContactsContract.Intents.Insert.NAME, name1);
                intent.putExtra(ContactsContract.Intents.Insert.PHONE, "" + number1);
                break;
            case R.id.save_contact_person_two:
                intent.putExtra(ContactsContract.Intents.Insert.NAME, name2);
                intent.putExtra(ContactsContract.Intents.Insert.PHONE, "" + number2);
                break;
            }
            startActivity(intent);
        }
    };

    assert callOne != null;
    callOne.setOnClickListener(callOnClickListener);
    assert callTwo != null;
    callTwo.setOnClickListener(callOnClickListener);
    assert saveOne != null;
    saveOne.setOnClickListener(saveOnClickListener);
    assert saveTwo != null;
    saveTwo.setOnClickListener(saveOnClickListener);
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * Launch the Dialer App./*from   w w w.  j  a va  2 s.c o m*/
 *
 * @param activity    context
 * @param phoneNumber to dial
 */
public static void launchPhoneIntent(Activity activity, String phoneNumber) {
    Intent intent = new Intent(Intent.ACTION_DIAL);
    intent.setData(Uri.parse("tel:" + phoneNumber));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    }
}

From source file:com.csipsimple.ui.calllog.CallLogListFragment.java

private void actionModeDialpad() {

    ListView lv = getListView();//from   ww w.  j  av a2  s.  co m

    for (int i = 0; i < lv.getCount(); i++) {
        if (lv.isItemChecked(i)) {
            mAdapter.getItem(i);
            String number = mAdapter.getCallRemoteAtPostion(i);
            if (!TextUtils.isEmpty(number)) {
                Intent it = new Intent(Intent.ACTION_DIAL);
                it.setData(SipUri.forgeSipUri(SipManager.PROTOCOL_SIP, number));
                startActivity(it);
            }
            break;
        }
    }
    mMode.invalidate();

}

From source file:com.nbplus.hybrid.BasicWebViewClient.java

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    // for excel download
    if (isDocumentMimeType(url)) {
        Log.d(TAG, "This url is document mimetype = " + url);
        if (StorageUtils.isExternalStorageWritable()) {
            Uri source = Uri.parse(url);

            // Make a new request pointing to the mp3 url
            DownloadManager.Request request = new DownloadManager.Request(source);
            // Use the same file name for the destination
            File destinationFile = new File(
                    Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
                    source.getLastPathSegment());
            request.setDestinationUri(Uri.fromFile(destinationFile));
            // Add it to the manager
            mDownloadManager.enqueue(request);
            Toast.makeText(mContext, R.string.downloads_requested, Toast.LENGTH_SHORT).show();
        } else {//from   ww w  . java2  s.co  m
            AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
            builder.setPositiveButton("?", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    //closeWebApplication();
                }
            });
            builder.setMessage(R.string.downloads_path_check);
            builder.show();
        }
        return true;
    }

    if (url.startsWith("tel:")) {
        // phone call
        if (!PhoneState.hasPhoneCallAbility(mContext)) {
            Log.d(TAG, ">> This device has not phone call ability !!!");
            return true;
        }

        mContext.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
    } else if (url.startsWith("mailto:")) {
        url = url.replaceFirst("mailto:", "");
        url = url.trim();

        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("plain/text").putExtra(Intent.EXTRA_EMAIL, new String[] { url });

        mContext.startActivity(i);
    } else if (url.startsWith("geo:")) {
        Intent searchAddress = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        mContext.startActivity(searchAddress);
    } else {
        //  URL ??   ? ??? .
        dismissProgressDialog();
        loadWebUrl(url);
        showProgressDialog();
    }
    return true;
}

From source file:jp.realglobe.sugo.actor.android.call.MainActivity.java

/**
 * ?/*from w w  w .j  a v  a 2s.c om*/
 */
private void talk() {
    final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    final String phoneNumber = preferences.getString(getString(R.string.key_phone_number), null);
    if (phoneNumber == null) {
        Log.e(LOG_TAG, "No phone number");
        showError("???????");
        return;
    }
    Log.d(LOG_TAG, "Call " + phoneNumber);
    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
        startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber)));
        return;
    }
    startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)));
}

From source file:com.misczak.joinmybridge.PhoneBookFragment.java

private void placePhoneCall(String number) {

    Intent dial;/*from  w w w . j av  a  2s.  c o  m*/

    if (customDialer == true) {
        dial = new Intent(Intent.ACTION_CALL, Uri.parse(number));
    } else {
        dial = new Intent(Intent.ACTION_DIAL, Uri.parse(number));
    }

    startActivity(dial);
}