List of usage examples for android.content Intent ACTION_CALL
String ACTION_CALL
To view the source code for android.content Intent ACTION_CALL.
Click Source Link
From source file:com.android.contacts.ShortcutIntentBuilder.java
private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData, String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) { final Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); final Bitmap icon; final Uri phoneUri; final String shortcutName; if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); }/*from ww w . j ava2 s.c o m*/ if (Intent.ACTION_CALL.equals(shortcutAction)) { // Make the URI a direct tel: URI so that it will always continue to work phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null); icon = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.quantum_ic_phone_vd_theme_24); shortcutName = mContext.getResources().getString(R.string.call_by_shortcut, displayName); } else { phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null); icon = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.quantum_ic_message_vd_theme_24); shortcutName = mContext.getResources().getString(R.string.sms_by_shortcut, displayName); } final Intent shortcutIntent = new Intent(shortcutAction, phoneUri); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = null; IconCompat compatAdaptiveIcon = null; if (BuildCompat.isAtLeastO()) { compatAdaptiveIcon = IconCompat.createWithAdaptiveBitmap(icon); final ShortcutManager sm = (ShortcutManager) mContext.getSystemService(Context.SHORTCUT_SERVICE); final String id = shortcutAction + lookupKey + phoneUri.toString().hashCode(); final DynamicShortcuts dynamicShortcuts = new DynamicShortcuts(mContext); final ShortcutInfo shortcutInfo = dynamicShortcuts.getActionShortcutInfo(id, displayName, shortcutIntent, compatAdaptiveIcon.toIcon()); if (shortcutInfo != null) { intent = sm.createShortcutResultIntent(shortcutInfo); } } intent = intent == null ? new Intent() : intent; // This will be non-null in O and above. if (compatAdaptiveIcon != null) { compatAdaptiveIcon.addToShortcutIntent(intent, null, mContext); } else { intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); } intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName); mListener.onShortcutIntentCreated(uri, intent); }
From source file:com.mstoyanov.music_lessons.ScheduleFragment.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.lessons_list: Cursor cursor = (Cursor) parent.getItemAtPosition(position); int studentId = cursor.getInt(cursor.getColumnIndex("studentID")); lessonId = cursor.getInt(cursor.getColumnIndex("_id")); String firstName = cursor.getString(cursor.getColumnIndex("firstName")); String lastName = cursor.getString(cursor.getColumnIndex("lastName")); if (dualPane) { selectionArgs_delete[0] = String.valueOf(lessonId); lessonsList.setItemChecked(position, true); selectedLesson = position;/*from ww w . jav a 2 s. c om*/ selectionArgs_actions[0] = String.valueOf(studentId); firstNameLabel.setText("First Name"); firstNameTextView.setText(firstName); lastNameLabel.setText("Last Name"); lastNameTextView.setText(lastName); getLoaderManager().restartLoader(ACTIONS_LOADER, null, this); } else { Intent intent = new Intent(getActivity(), LessonDetailsActivity.class); intent.putExtra("LESSON_ID", lessonId); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } break; case R.id.actions_list: Actions action = actions.get(position); switch (action.getType()) { case Actions.ACTION_CALL: Uri callUri = Uri.parse("tel:" + action.getData()); Intent intent = new Intent(Intent.ACTION_CALL, callUri); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); break; case Actions.ACTION_EMAIL: intent = new Intent(Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { action.getData() }); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); break; case Actions.ACTION_SMS: Uri smsUri = Uri.parse("sms:" + action.getData()); intent = new Intent(Intent.ACTION_VIEW, smsUri); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); break; default: throw new IllegalArgumentException("Invalid action type: " + action.getType()); } break; default: throw new IllegalArgumentException("Invalid parentId: " + parent.getId()); } }
From source file:com.android.contacts.activities.ContactSelectionActivity.java
/** * Creates the fragment based on the current request. *//*from w w w .j av a2 s . c o m*/ public void configureListFragment() { switch (mActionCode) { case ContactsRequest.ACTION_INSERT_OR_EDIT_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setEditMode(true); fragment.setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_NONE); fragment.setCreateContactEnabled(!mRequest.isSearchMode()); fragment.setListType(ListEvent.ListType.PICK_CONTACT); mListFragment = fragment; break; } case ContactsRequest.ACTION_DEFAULT: case ContactsRequest.ACTION_PICK_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setIncludeFavorites(mRequest.shouldIncludeFavorites()); fragment.setListType(ListEvent.ListType.PICK_CONTACT); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_OR_CREATE_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setCreateContactEnabled(!mRequest.isSearchMode()); fragment.setListType(ListEvent.ListType.PICK_CONTACT); mListFragment = fragment; break; } case ContactsRequest.ACTION_CREATE_SHORTCUT_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setShortcutRequested(true); fragment.setListType(ListEvent.ListType.PICK_CONTACT_FOR_SHORTCUT); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_PHONE: { PhoneNumberPickerFragment fragment = getPhoneNumberPickerFragment(mRequest); fragment.setListType(ListEvent.ListType.PICK_PHONE); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_EMAIL: { mListFragment = new EmailAddressPickerFragment(); mListFragment.setListType(ListEvent.ListType.PICK_EMAIL); break; } case ContactsRequest.ACTION_PICK_PHONES: { mListFragment = new MultiSelectPhoneNumbersListFragment(); mListFragment.setArguments(getIntent().getExtras()); break; } case ContactsRequest.ACTION_PICK_EMAILS: { mListFragment = new MultiSelectEmailAddressesListFragment(); mListFragment.setArguments(getIntent().getExtras()); break; } case ContactsRequest.ACTION_CREATE_SHORTCUT_CALL: { PhoneNumberPickerFragment fragment = getPhoneNumberPickerFragment(mRequest); fragment.setShortcutAction(Intent.ACTION_CALL); fragment.setListType(ListEvent.ListType.PICK_CONTACT_FOR_SHORTCUT); mListFragment = fragment; break; } case ContactsRequest.ACTION_CREATE_SHORTCUT_SMS: { PhoneNumberPickerFragment fragment = getPhoneNumberPickerFragment(mRequest); fragment.setShortcutAction(Intent.ACTION_SENDTO); fragment.setListType(ListEvent.ListType.PICK_CONTACT_FOR_SHORTCUT); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_POSTAL: { PostalAddressPickerFragment fragment = new PostalAddressPickerFragment(); fragment.setListType(ListEvent.ListType.PICK_POSTAL); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_JOIN: { JoinContactListFragment joinFragment = new JoinContactListFragment(); joinFragment.setTargetContactId(getTargetContactId()); joinFragment.setListType(ListEvent.ListType.PICK_JOIN); mListFragment = joinFragment; break; } case ContactsRequest.ACTION_PICK_GROUP_MEMBERS: { final String accountName = getIntent().getStringExtra(UiIntentActions.GROUP_ACCOUNT_NAME); final String accountType = getIntent().getStringExtra(UiIntentActions.GROUP_ACCOUNT_TYPE); final String accountDataSet = getIntent().getStringExtra(UiIntentActions.GROUP_ACCOUNT_DATA_SET); final ArrayList<String> contactIds = getIntent() .getStringArrayListExtra(UiIntentActions.GROUP_CONTACT_IDS); mListFragment = GroupMemberPickerFragment.newInstance(accountName, accountType, accountDataSet, contactIds); mListFragment.setListType(ListEvent.ListType.PICK_GROUP_MEMBERS); break; } default: throw new IllegalStateException("Invalid action code: " + mActionCode); } // Setting compatibility is no longer needed for PhoneNumberPickerFragment since that logic // has been separated into LegacyPhoneNumberPickerFragment. But we still need to set // compatibility for other fragments. mListFragment.setLegacyCompatibilityMode(mRequest.isLegacyCompatibilityMode()); mListFragment.setDirectoryResultLimit(DEFAULT_DIRECTORY_RESULT_LIMIT); getFragmentManager().beginTransaction().replace(R.id.list_container, mListFragment) .commitAllowingStateLoss(); }
From source file:ca.mymenuapp.ui.activities.RestaurantActivity.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case R.id.restaurant_call: Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + menu.getRestaurant().businessNumber)); if (isAvailable(this, intent)) { startActivity(intent);/*from www. j a va2 s . co m*/ } return true; case R.id.restaurant_info: final RestaurantInfoDialogFragment fragment = RestaurantInfoDialogFragment .newInstance(menu.getRestaurant()); fragment.show(getFragmentManager(), "info"); return true; default: return super.onMenuItemSelected(featureId, item); } }
From source file:com.oscarsalguero.dialer.MainActivity.java
/** * Dials a phone number using the ACTION_CALL intent (requires CALL_PHONE permission). */// www .j a v a2s . c om private void callPhone() { try { String phoneNumber = textViewDisplay.getText().toString(); Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse(URI_PREFIX_TEL + Uri.encode(phoneNumber))); startActivity(callIntent); logPhoneNumber(phoneNumber); } catch (SecurityException e) { Log.e(LOG_TAG, "An exception occurred trying to execute the CALL intent.", e); } }
From source file:com.corporatetaxi.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 ww w. j a va2 s .c om // getSupportActionBar().setDisplayHomeAsUpEnabled(true); String title = getString(R.string.title_activity_taxidetail); getSupportActionBar().setTitle(title); fab_menu = (FloatingActionsMenu) findViewById(R.id.fab_menu); fab_msg = (FloatingActionButton) findViewById(R.id.fab_message); fab_call = (FloatingActionButton) findViewById(R.id.fab_call); 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); taxiname = (TextView) findViewById(R.id.taxinametext); mtextnamehead = (TextView) findViewById(R.id.namehead); mtextcompanyhead = (TextView) findViewById(R.id.companyhead); mtextmobilehead = (TextView) findViewById(R.id.mobilehead); mtexttexinumhead = (TextView) findViewById(R.id.taxiplatthead); taxinamehead = (TextView) findViewById(R.id.taxinamehead); mdriverimage = (ImageView) findViewById(R.id.driver_image); mdriverlicense = (TextView) findViewById(R.id.driverlicense); medriverinsurance = (TextView) findViewById(R.id.driverinsurance); 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); taxinamehead.setTypeface(tf); taxiname.setTypeface(tf); mdriverlicense.setTypeface(tf); medriverinsurance.setTypeface(tf); ////////current date time////////////////// currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); Log.d("currentdatetime", currentDateTimeString); /////back arrow //////////// // final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha); // upArrow.setColorFilter(getResources().getColor(R.color.colorbutton), PorterDuff.Mode.SRC_ATOP); // getSupportActionBar().setHomeAsUpIndicator(upArrow); /////////////notification data/////////////// 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("driveriamge", driverimage); final LatLng loc = new LatLng(new Double(sourcelatitude), new Double(sourcelongitude)); map.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 15)); MarkerOptions marker = new MarkerOptions().position(loc).title(SourceAddress); marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_three)); map.addMarker(marker); textname.setText(drivername); textmobilenumber.setText(drivermobile); textcompanyname.setText(drivercompanyname); texttaxinumber.setText(drivertexinumber); taxiname.setText(drivertaxiname); mdriverlicense.setText(driverlicense); medriverinsurance.setText(driverinsurance); if (mdriverlicense.length() == 0) { mdriverlicense.setVisibility(View.GONE); } if (medriverinsurance.length() == 0) { medriverinsurance.setVisibility(View.GONE); } Intent intent1 = new Intent(TaxiOntheWay_Activity.this, DriverService.class); intent1.putExtra("driverId", jsonObject.getString("driverId")); startService(intent1); // loc2 = new LatLng(driverlatitude, driverlongitude); // MarkerOptions marker2 = new MarkerOptions().position(loc2); // marker2.icon(BitmapDescriptorFactory.fromResource(R.drawable.drivertaxi)); // map.addMarker(marker2); 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))); MarkerOptions marker2 = new MarkerOptions().position(loc2); map.clear(); marker2.icon(BitmapDescriptorFactory.fromResource(R.drawable.drivertaxi)); map.addMarker(marker2.title(drivername));*/ 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); } }); } }, 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); } }); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); 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); } }
From source file:jp.realglobe.sugo.actor.android.call.MainActivity.java
/** * ?/*from www .java 2s . c o m*/ */ 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;//w w w . j av a2 s. 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); }
From source file:com.silentcircle.contacts.activities.ScContactSelectionActivity.java
/** * Creates the fragment based on the current request. *///from ww w.j a v a 2 s.c o m public void configureListFragment() { switch (mActionCode) { case ContactsRequest.ACTION_INSERT_OR_EDIT_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setEditMode(true); fragment.setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_NONE); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setIncludeProfile(mRequest.shouldIncludeProfile()); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_OR_CREATE_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); mListFragment = fragment; break; } case ContactsRequest.ACTION_CREATE_SHORTCUT_CONTACT: { ContactPickerFragment fragment = new ContactPickerFragment(); fragment.setShortcutRequested(true); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_PHONE: { PhoneNumberPickerFragment fragment = new PhoneNumberPickerFragment(); fragment.setUseCallableUri(true); mListFragment = fragment; break; } case ContactsRequest.ACTION_PICK_EMAIL: { mListFragment = new EmailAddressPickerFragment(); break; } case ContactsRequest.ACTION_CREATE_SHORTCUT_CALL: { PhoneNumberPickerFragment fragment = new PhoneNumberPickerFragment(); fragment.setShortcutAction(Intent.ACTION_CALL); mListFragment = fragment; break; } case ContactsRequest.ACTION_CREATE_SHORTCUT_SMS: { PhoneNumberPickerFragment fragment = new PhoneNumberPickerFragment(); fragment.setShortcutAction(Intent.ACTION_SENDTO); mListFragment = fragment; break; } // case ContactsRequest.ACTION_PICK_POSTAL: { // PostalAddressPickerFragment fragment = new PostalAddressPickerFragment(); // mListFragment = fragment; // break; // } default: throw new IllegalStateException("Invalid action code: " + mActionCode); } mListFragment.setLegacyCompatibilityMode(mRequest.isLegacyCompatibilityMode()); mListFragment.setDirectoryResultLimit(DEFAULT_DIRECTORY_RESULT_LIMIT); getSupportFragmentManager().beginTransaction().replace(R.id.list_container, mListFragment) .commitAllowingStateLoss(); }