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:com.king.base.util.SystemUtils.java

/**
 * ??/*w w w  .  ja  v a  2  s  . co  m*/
 *
 * @param context
 * @param phoneNumber
 */
public static void call(Context context, String phoneNumber) {

    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(String.format("tel:%s", phoneNumber)));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    context.startActivity(intent);
}

From source file:com.pimp.instincts.activities.HospitalityActivity.java

public void contactClick3(View view) {
    startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+91 89 39 619640")));
}

From source file:ayushi.view.fragment.ContactUsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.frag_about, container, false);

    getActivity().setTitle("Contact Us");

    mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar);
    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar);
    }/*from  w w  w .  j a  v  a  2s  .  c om*/

    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mToolbar.setNavigationIcon(R.drawable.ic_drawer);

    }

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START);
        }
    });

    mToolbar.setTitleTextColor(Color.WHITE);

    rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

        }
    });

    rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

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

        }
    });

    rootView.setFocusableInTouchMode(true);
    rootView.requestFocus();
    rootView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {

                Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT,
                        ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP);

            }
            return true;
        }
    });

    rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://hiteshsahu.com/"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("text/plain");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                    new String[] { "hiteshkumarsahu1990@gmail.com" });
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There");
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here");

            emailIntent.setType("message/rfc822");

            try {
                startActivity(Intent.createChooser(emailIntent, "Send email using..."));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show();
            }

        }
    });

    return rootView;
}

From source file:io.github.marktony.espresso.mvp.companydetails.CompanyDetailFragment.java

@Nullable
@Override/*from   w w w.j  av  a  2 s  . c  o  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_company_details, container, false);

    initViews(view);

    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            share();
        }
    });

    textViewTel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tel != null && !tel.isEmpty()) {
                Intent intent = new Intent(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:" + tel));
                getActivity().startActivity(intent);
            }
        }
    });

    textViewWebsite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (website != null) {
                CustomTabsHelper.openUrl(getContext(), website);
            }
        }
    });

    setHasOptionsMenu(true);

    return view;
}

From source file:com.hitesh_sahu.retailapp.view.fragment.ContactUsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.frag_about, container, false);

    getActivity().setTitle("Contact Us");

    mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar);
    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar);
    }//  w  ww.  ja va 2s  . com

    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mToolbar.setNavigationIcon(R.drawable.ic_drawer);

    }

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START);
        }
    });

    mToolbar.setTitleTextColor(Color.WHITE);

    rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

        }
    });

    rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

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

        }
    });

    rootView.setFocusableInTouchMode(true);
    rootView.requestFocus();
    rootView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {

                Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT,
                        ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP);

            }
            return true;
        }
    });

    rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://hiteshsahu.com/"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("text/plain");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hiteshkrsahu@gmail.com" });
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There");
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here");

            emailIntent.setType("message/rfc822");

            try {
                startActivity(Intent.createChooser(emailIntent, "Send email using..."));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show();
            }

        }
    });

    return rootView;
}

From source file:com.Bhailal_Chauhan.retailapp.view.fragment.ContactUsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.frag_about, container, false);

    getActivity().setTitle("Contact Us");

    mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar);
    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar);
    }// www  .j a va  2  s.  c o m

    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mToolbar.setNavigationIcon(R.drawable.ic_drawer);

    }

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START);
        }
    });

    mToolbar.setTitleTextColor(Color.WHITE);

    rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

        }
    });

    rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

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

        }
    });

    rootView.setFocusableInTouchMode(true);
    rootView.requestFocus();
    rootView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {

                Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT,
                        ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP);

            }
            return true;
        }
    });

    rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bhailalchauhan.com/"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("text/plain");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hibhailal458@gmail.com" });
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There");
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here");

            emailIntent.setType("message/rfc822");

            try {
                startActivity(Intent.createChooser(emailIntent, "Send email using..."));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show();
            }

        }
    });

    return rootView;
}

From source file:com.trupti_prajapati.retailapp.view.fragment.ContactUsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.frag_contactus, container, false);

    getActivity().setTitle("Contact Us");

    mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar);
    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar);
    }/*from  w w  w.  ja va  2  s  . com*/

    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mToolbar.setNavigationIcon(R.drawable.ic_drawer);

    }

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START);
        }
    });

    mToolbar.setTitleTextColor(Color.WHITE);

    rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

        }
    });

    rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

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

        }
    });

    rootView.setFocusableInTouchMode(true);
    rootView.requestFocus();
    rootView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {

                Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT,
                        ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP);

            }
            return true;
        }
    });

    rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://github.com/truptinprajapati"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("text/plain");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                    new String[] { "truptiprajapati19@gmail.com" });
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There");
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here");

            emailIntent.setType("message/rfc822");

            try {
                startActivity(Intent.createChooser(emailIntent, "Send email using..."));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show();
            }

        }
    });

    return rootView;
}

From source file:net.evecom.androidecssp.activity.pub.EmergencyNotification.java

/**
 * /*from   w w  w  .j  a v  a2s.  c o  m*/
 *  call
 * 
 * @author Mars zhang
 * @created 2015-11-17 4:46:30
 * @param view
 */
public void call(View view) {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:18950478288"));
    startActivity(intent);
    finish();
}

From source file:com.hch.beautyenjoy.tools.IntentUtils.java

/**
 * Open dial with a number//  w  w  w  . j  ava2s  .c  om
 */
public static void openDial(Context context, String number) {
    Uri uri = Uri.parse("tel:" + number);
    Intent intent = new Intent(Intent.ACTION_DIAL, uri);
    ComponentName componentName = intent.resolveActivity(context.getPackageManager());
    if (componentName != null) {
        context.startActivity(intent);
    }
}

From source file:ca.etsmtl.applets.etsmobile.SecurityActivity.java

@Override
protected void onCreate(final android.os.Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.security);/*from w  w w  .  j  a  v  a 2s .c o  m*/

    navBar = (NavBar) findViewById(R.id.navBar1);
    navBar.setTitle(getString(R.string.secu_title));
    navBar.hideLoading();
    navBar.hideRightButton();
    listView = (ListView) findViewById(android.R.id.list);

    final ViewGroup viewGroup = (ViewGroup) getLayoutInflater().inflate(R.layout.secu_list_header,
            (ViewGroup) findViewById(R.id.secu_list_header_layout));
    listView.addHeaderView(viewGroup, null, false);

    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> arg0, final View arg1, final int arg2, final long arg3) {
            final Intent intent = new Intent(getApplicationContext(), UrgenceActivity.class);
            intent.putExtra("id", arg2);
            startActivity(intent);

        }
    });
    listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
            getResources().getStringArray(R.array.secu_urgence)));

    viewGroup.findViewById(R.id.secu_list_header_phone).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            final String phoneNumber = ((TextView) v).getText().toString();
            final String uri = "tel:" + phoneNumber.trim();
            final Intent intent = new Intent(Intent.ACTION_DIAL);
            intent.setData(Uri.parse(uri));
            startActivity(intent);
        }
    });

    final SupportMapFragment map = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    final GoogleMap mapView = map.getMap();

    if (mapView != null) {
        mapView.getUiSettings().setZoomControlsEnabled(false);
        mapView.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), 17));

        final MarkerOptions etsMarker = new MarkerOptions();
        etsMarker.position(new LatLng(lat, lng));
        etsMarker.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon));
        mapView.addMarker(etsMarker);
    } else {
        map.getView().setVisibility(View.GONE);
    }
}