Example usage for android.content Intent ACTION_CALL

List of usage examples for android.content Intent ACTION_CALL

Introduction

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

Prototype

String ACTION_CALL

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

Click Source Link

Document

Activity Action: Perform a call to someone specified by the data.

Usage

From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.MessagesActivity.java

private void callPhone() {
    if ((mGroup == null) && (mUser == null)) {
        log.warn("Group and user not set, cannot call");
        return;//from   w w w. ja  v  a 2 s  .c o m
    }

    String uri = null;
    if (mGroup != null) {
        if (mGroup.getPhone().equals(ConstantKeys.STRING_DEFAULT)) {
            Toast.makeText(getApplicationContext(), getApplicationContext().getText(R.string.popup_call_error),
                    Toast.LENGTH_SHORT).show();
            return;
        }
        uri = ConstantKeys.CALL_PHONE + mGroup.getPhone().trim();
    } else if (mUser != null) {
        if (mUser.getPhone().equals(ConstantKeys.STRING_DEFAULT)) {
            Toast.makeText(getApplicationContext(), getApplicationContext().getText(R.string.popup_call_error),
                    Toast.LENGTH_SHORT).show();
            return;
        }
        uri = ConstantKeys.CALL_PHONE + mUser.getPhone().trim();
    } else {
        return;
    }

    Intent intent = new Intent(Intent.ACTION_CALL);
    intent.setData(Uri.parse(uri));

    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {

        return;
    }
    startActivity(intent);
}

From source file:com.usertaxi.TaxiOntheWay_Activity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_taxiontheway);

    taxiOntheWay_activity_instance = this;
    AppPreferences.setApprequestTaxiScreen(TaxiOntheWay_Activity.this, true);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.BLACK);
    setSupportActionBar(toolbar);//from w w w.  j a  v  a 2 s.com
    String title = getString(R.string.title_activity_taxidetail);
    getSupportActionBar().setTitle(title);
    fab_menu = (FloatingActionsMenu) findViewById(R.id.fab_menu);
    FloatingActionButton fab_msg = (FloatingActionButton) findViewById(R.id.fab_message);
    FloatingActionButton fab_call = (FloatingActionButton) findViewById(R.id.fab_call);
    FloatingActionButton fab_cancel = (FloatingActionButton) findViewById(R.id.fab_cancel);

    textheader = (TextView) findViewById(R.id.textheader);
    textname = (TextView) findViewById(R.id.name_text);
    textmobilenumber = (TextView) findViewById(R.id.mobile_text);
    textcompanyname = (TextView) findViewById(R.id.companyname);
    texttaxinumber = (TextView) findViewById(R.id.taxinumber);
    mtextnamehead = (TextView) findViewById(R.id.namehead);
    mtextcompanyhead = (TextView) findViewById(R.id.companyhead);
    mtextmobilehead = (TextView) findViewById(R.id.mobilehead);
    mtexttexinumhead = (TextView) findViewById(R.id.taxiplatthead);
    mdriverlicense = (TextView) findViewById(R.id.driverlicense);
    medriverinsurance = (TextView) findViewById(R.id.driverinsurance);
    mdriverimage = (ImageView) findViewById(R.id.driver_image);

    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);

    getLocation();

    Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");
    textheader.setTypeface(tf);
    mtextnamehead.setTypeface(tf);
    mtextcompanyhead.setTypeface(tf);
    mtextmobilehead.setTypeface(tf);
    mtexttexinumhead.setTypeface(tf);
    textname.setTypeface(tf);
    textmobilenumber.setTypeface(tf);
    textcompanyname.setTypeface(tf);
    texttaxinumber.setTypeface(tf);
    mdriverlicense.setTypeface(tf);
    medriverinsurance.setTypeface(tf);

    Intent intent = getIntent();
    String data = intent.getStringExtra("data");
    Log.d("data value", data + "");

    //caceldialog();
    JSONObject jsonObject = null;
    try {
        jsonObject = new JSONObject(data);
        AppPreferences.setAcceptdriverId(TaxiOntheWay_Activity.this, jsonObject.getString("driverId"));
        Log.d("driverid---", AppPreferences.getAcceptdriverId(TaxiOntheWay_Activity.this));
        drivermobile = jsonObject.getString("mobile");
        drivername = jsonObject.getString("username");
        drivercompanyname = jsonObject.getString("taxicompany");
        drivertaxiname = jsonObject.getString("vehicalname");
        drivertexinumber = jsonObject.getString("vehicle_number");
        //driverlatitude = jsonObject.getDouble("latitude");
        //driverlongitude = jsonObject.getDouble("longitude");
        driverimage = jsonObject.getString("driverImage");
        SourceAddress = jsonObject.getString("source_address");
        sourcelatitude = jsonObject.getDouble("source_latitude");
        sourcelongitude = jsonObject.getDouble("source_longitude");
        driverlicense = jsonObject.getString("driverlicense");
        driverinsurance = jsonObject.getString("driverinsurance");

        //            Log.d("longitudeeeee:------", String.valueOf(jsonObject.getDouble("longitude")));

        final LatLng loc = new LatLng(new Double(sourcelatitude), new Double(sourcelongitude));
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 15));
        final MarkerOptions marker = new MarkerOptions().position(loc).title(SourceAddress);
        //  marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));

        marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_three));
        map.addMarker(marker);

        textname.setText(drivername);
        textmobilenumber.setText(drivermobile);
        textcompanyname.setText(drivercompanyname);
        texttaxinumber.setText(drivertexinumber);
        mdriverlicense.setText(driverlicense);
        medriverinsurance.setText(driverinsurance);

        if (mdriverlicense.length() == 0) {
            mdriverlicense.setVisibility(View.GONE);
        }
        if (medriverinsurance.length() == 0) {
            medriverinsurance.setVisibility(View.GONE);
        }
        //taxiname.setText(drivertaxiname);

        Intent intent1 = new Intent(TaxiOntheWay_Activity.this, DriverService.class);
        intent1.putExtra("driverId", jsonObject.getString("driverId"));
        startService(intent1);

        if (driverimage.equalsIgnoreCase("")) {
            mdriverimage.setImageResource(R.drawable.ic_action_user);
        } else {
            Picasso.with(getApplicationContext()).load(driverimage).error(R.drawable.ic_action_user)
                    .resize(200, 200).into(mdriverimage);
        }

        Timer timer;
        TimerTask task;
        int delay = 10000;
        int period = 10000;

        timer = new Timer();

        timer.scheduleAtFixedRate(task = new TimerTask() {
            public void run() {

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        loc2 = new LatLng(new Double(AppPreferences.getCurrentlat(TaxiOntheWay_Activity.this)),
                                new Double(AppPreferences.getCurrentlong(TaxiOntheWay_Activity.this)));

                        if (marker1 == null) {
                            marker1 = map.addMarker(new MarkerOptions().position(loc2).title(drivername)
                                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.drivertaxi)));

                        }
                        animateMarker(marker1, loc2, false);

                        /* try{
                             String url = Function.getDirectionsUrl(new LatLng(Double.parseDouble(AppPreferences.getPreviouslat(getApplicationContext())),
                                     Double.parseDouble(AppPreferences.getPreviouslong(getApplicationContext()))),
                                     new LatLng(Double.parseDouble(AppPreferences.getCurrentlat(getApplicationContext())),
                                             Double.parseDouble(AppPreferences.getCurrentlong(getApplicationContext()))));
                             RoutesDownloadTask downloadTask = new RoutesDownloadTask(TaxiOntheWay_Activity.this);
                             downloadTask.execute(url);
                         }catch(Exception e)
                         {
                             e.printStackTrace();
                         }*/
                    }
                });
            }
        }, delay, period);

    } catch (JSONException e) {
        e.printStackTrace();
    }
    /////////////notification dataend///////////////

    fab_cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            initiatePopupWindowcanceltaxi();

        }
    });
    fab_msg.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            initiatePopupWindowsendmesage();
        }
    });
    fab_call.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse("tel:" + drivermobile));
            startActivity(callIntent);
        }
    });

    moveMarkerList = new ArrayList<LatLng>();
    //        moveRoadMarker();
}

From source file:com.oo58.game.texaspoker.AppActivity.java

public static void callCustomService(final String number) {
    final Activity ctx = mAct;
    ctx.runOnUiThread(new Runnable() {
        @Override/*from   w  w  w.  j a  v a2 s.  co  m*/
        public void run() {
            // TODO Auto-generated method stub
            try {
                Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number));
                ctx.startActivity(intent);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });
}

From source file:com.yj.smarthome.activity.control.MainControlActivity.java

/**
 * Inits the views.//from  w  ww.j a v  a  2s.  c  o m
 */
private void initViews() {
    tv_camera = (TextView) findViewById(R.id.tvCamera);
    mViewPager = (ViewPager) findViewById(R.id.pager);

    pagerTabStrip = (PagerTabStrip) findViewById(R.id.pager_tab_strip);
    // 
    pagerTabStrip.setTextSize(TypedValue.COMPLEX_UNIT_PX, 50);
    //
    pagerTabStrip.setTabIndicatorColor(getResources().getColor(R.color.indicatorcolor));

    myPagerAdapter = new MyPagerAdapter();
    mViewPager.setAdapter(myPagerAdapter);

    rlAlarmTips = (RelativeLayout) findViewById(R.id.rlAlarmTips);
    tvAlarmTipsCount = (TextView) findViewById(R.id.tvAlarmTipsCount);
    drawerLayout = (DrawerLayout) findViewById(R.id.main_layout);
    rlControlMainPage = (RelativeLayout) findViewById(R.id.rlControlMainPage);
    ivMenu = (ImageView) findViewById(R.id.ivMenu);
    tvTitle = (TextView) findViewById(R.id.tvTitle);
    mFaultDialog = DialogManager.getDeviceErrirDialog(MainControlActivity.this, "",
            new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:10010"));
                    startActivity(intent);
                    mFaultDialog.dismiss();
                }
            });
    mAdapter = new MenuDeviceAdapter(this, bindlist);

    progressDialogRefreshing = new ProgressDialog(MainControlActivity.this);
    progressDialogRefreshing.setMessage("?,??");
    progressDialogRefreshing.setCancelable(false);
    mDisconnectDialog = DialogManager.getDisconnectDialog(this, new OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogManager.dismissDialog(MainControlActivity.this, mDisconnectDialog);
            IntentUtils.getInstance().startActivity(MainControlActivity.this, DeviceListActivity.class);
            finish();
        }
    });
    //???
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer_am,
            R.string.open_darwlayout, R.string.close_darwlayout) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);
    drawerToggle.syncState();
}

From source file:appteam.nith.hillffair.activities.HomeActivity.java

private void call(int i) {
    // Check the SDK version and whether the permission is already granted or not.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
            && checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(new String[] { Manifest.permission.CALL_PHONE }, PERMISSIONS_REQUEST_PHONE_CALL);
    } else {//ww  w . j av  a 2 s .co  m
        //Open call function
        String phone = number[i];
        Intent intent = new Intent(Intent.ACTION_CALL);
        intent.setData(Uri.parse("tel:+91" + phone));
        startActivity(intent);
    }
}

From source file:com.csipsimple.service.SipNotifications.java

public void showNotificationForVoiceMail(SipProfile acc, int numberOfMessages) {
    if (messageVoicemail == null) {

        messageVoicemail = new NotificationCompat.Builder(context);
        messageVoicemail.setSmallIcon(android.R.drawable.stat_notify_voicemail);
        messageVoicemail.setTicker(context.getString(R.string.voice_mail));
        messageVoicemail.setWhen(System.currentTimeMillis());
        messageVoicemail.setDefaults(Notification.DEFAULT_ALL);
        messageVoicemail.setAutoCancel(true);
        messageVoicemail.setOnlyAlertOnce(true);
    }/*from   w ww .  j a v a2s.c  o m*/

    PendingIntent contentIntent = null;
    Intent notificationIntent;
    if (acc != null && !TextUtils.isEmpty(acc.vm_nbr) && acc.vm_nbr != "null") {
        notificationIntent = new Intent(Intent.ACTION_CALL);
        notificationIntent.setData(
                SipUri.forgeSipUri(SipManager.PROTOCOL_CSIP, acc.vm_nbr + "@" + acc.getDefaultDomain()));
        notificationIntent.putExtra(SipProfile.FIELD_ACC_ID, acc.id);
    } else {
        notificationIntent = new Intent(SipManager.ACTION_SIP_DIALER);
    }
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    contentIntent = PendingIntent.getActivity(context, 0, notificationIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    String messageText = "";
    if (acc != null) {
        messageText += acc.getProfileName() + " : ";
    }
    messageText += Integer.toString(numberOfMessages);

    messageVoicemail.setContentTitle(context.getString(R.string.voice_mail));
    messageVoicemail.setContentText(messageText);
    if (contentIntent != null) {
        messageVoicemail.setContentIntent(contentIntent);
        notificationManager.notify(VOICEMAIL_NOTIF_ID, messageVoicemail.build());
    }
}

From source file:com.sip.pwc.sipphone.service.SipNotifications.java

public void showNotificationForVoiceMail(SipProfile acc, int numberOfMessages) {
    if (messageVoicemail == null) {

        messageVoicemail = new NotificationCompat.Builder(context);
        messageVoicemail.setSmallIcon(android.R.drawable.stat_notify_voicemail);
        messageVoicemail.setTicker(context.getString(R.string.voice_mail));
        messageVoicemail.setWhen(System.currentTimeMillis());
        messageVoicemail.setDefaults(Notification.DEFAULT_ALL);
        messageVoicemail.setAutoCancel(true);
        messageVoicemail.setOnlyAlertOnce(true);
    }//w w w  . j  ava  2 s  . c  o  m

    PendingIntent contentIntent = null;
    Intent notificationIntent;
    if (acc != null && !TextUtils.isEmpty(acc.vm_nbr) && acc.vm_nbr != "null") {
        notificationIntent = new Intent(Intent.ACTION_CALL);
        notificationIntent.setData(
                SipUri.forgeSipUri(SipManager.PROTOCOL_CSIP, acc.vm_nbr + "@" + acc.getDefaultDomain()));
        notificationIntent.putExtra(SipProfile.FIELD_ACC_ID, acc.id);
    } else {
        notificationIntent = new Intent(SipManager.ACTION_SIP_DIALER);
    }
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    contentIntent = PendingIntent.getActivity(context, 0, notificationIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    String messageText = "";
    if (acc != null) {
        messageText += acc.getProfileName();
        if (numberOfMessages > 0) {
            messageText += " : ";
        }
    }
    if (numberOfMessages > 0) {
        messageText += Integer.toString(numberOfMessages);
    }

    messageVoicemail.setContentTitle(context.getString(R.string.voice_mail));
    messageVoicemail.setContentText(messageText);
    if (contentIntent != null) {
        messageVoicemail.setContentIntent(contentIntent);
        notificationManager.notify(VOICEMAIL_NOTIF_ID, messageVoicemail.build());
    }
}

From source file:com.vyasware.vaani.MainActivity.java

private void doCall(String noun) {
    System.out.println("call");
    System.out.println(noun);/*from  w  w w  . j  a v  a  2  s . c  om*/

    Cursor cur = null;
    ContentResolver cr = null;

    try {
        cr = getContentResolver();

    } catch (Exception ex) {
        ex.printStackTrace();
    }

    try {
        cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    try {
        boolean called = false;
        if (cur.getCount() > 0) {
            while (cur.moveToNext()) {

                String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
                String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                // Log.i("Names", name);
                if (Integer.parseInt(
                        cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
                    // Query phone here. Covered next
                    Cursor phones = getContentResolver().query(
                            ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
                            ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + id, null, null);
                    while (phones.moveToNext()) {
                        String phoneNumberX = phones.getString(
                                phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                        // Log.i("Number", phoneNumber);
                        boolean a = (name.equalsIgnoreCase(noun));
                        System.out.println(name + "  " + a + "  " + phoneNumberX);

                        if (a)
                            System.out.println(phoneNumberX);

                        if (a) {
                            String b = "tel:";
                            String phoneCallUri = b + phoneNumberX;
                            Intent phoneCallIntent = new Intent(Intent.ACTION_CALL);
                            phoneCallIntent.setData(Uri.parse(phoneCallUri));
                            called = true;
                            startActivity(phoneCallIntent);

                        }

                    }
                    phones.close();

                }

            }

            if (!called)
                tts.speak(noun + "  ?    !",
                        TextToSpeech.QUEUE_FLUSH, null);

        }

    } catch (Exception ex) {
        ex.printStackTrace();

    }
    // tts.speak(noun + "  ?    !",TextToSpeech.QUEUE_FLUSH, null);
}

From source file:com.roamprocess1.roaming4world.ui.calllog.CallLogListFragment.java

@Override
public void placeCall(String number, Long accId) {
    if (!TextUtils.isEmpty(number)) {

        System.out.println("CallLogListFragment Step 18");
        System.out.println("Call list Fragment ==== placeCall ");
        prefs.edit().putString(stored_lastdialnumber, number).commit();
        Intent it = new Intent(Intent.ACTION_CALL);
        it.setData(SipUri.forgeSipUri(SipManager.PROTOCOL_CSIP, SipUri.getCanonicalSipContact(number, false)));
        it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (accId != null) {
            System.out.println("CallLogListFragment Step 19");

            it.putExtra(SipProfile.FIELD_ACC_ID, accId);
        }//  ww  w  .jav  a2 s  .c o  m
        getActivity().startActivity(it);
    }
}

From source file:cx.ring.client.HomeActivity.java

@Override
public void onCallDialed(String to) {
    Intent intent = new Intent().setClass(this, CallActivity.class).setAction(Intent.ACTION_CALL)
            .setData(Uri.parse(to));/*  w  w w.jav a2  s . com*/
    startActivityForResult(intent, REQUEST_CODE_CALL);
}