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.mstoyanov.music_lessons.StudentsFragment.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (parent.getId()) { case R.id.students_list: Cursor cursor = (Cursor) parent.getItemAtPosition(position); studentId = cursor.getInt(cursor.getColumnIndex("_id")); String firstName = cursor.getString(cursor.getColumnIndex("firstName")); String lastName = cursor.getString(cursor.getColumnIndex("lastName")); if (dualPane) { studentsList.setItemChecked(position, true); selectedStudent = position;// www .java 2s . co m selectionArgs[0] = String.valueOf(studentId); firstNameLabel.setText("First Name"); firstNameTextView.setText(firstName); lastNameLabel.setText("Last Name"); lastNameTextView.setText(lastName); getLoaderManager().restartLoader(STUDENT_DETAILS_LOADER, null, this); } else { Intent intent = new Intent(getActivity(), StudentDetailsActivity.class); intent.putExtra("STUDENT_ID", studentId); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } break; case R.id.student_details_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); default: throw new IllegalArgumentException("Invalid action type: " + action.getType()); } default: throw new IllegalArgumentException("Invalid parentId: " + parent.getId()); } }
From source file:com.gsma.rcs.ri.sharing.image.InitiateImageSharing.java
private void initialize() { mImageSharingService = getImageSharingApi(); mSpinner = (Spinner) findViewById(R.id.contact); ContactListAdapter adapter = ContactListAdapter.createRcsContactListAdapter(this); mSpinner.setAdapter(adapter);/* ww w. ja v a2 s. c om*/ OnClickListener btnInviteListener = new OnClickListener() { public void onClick(View v) { // Check if the service is available try { if (!mImageSharingService.isServiceRegistered()) { showMessage(R.string.error_not_registered); return; } // Get the remote contact ContactListAdapter adapter = (ContactListAdapter) mSpinner.getAdapter(); String phoneNumber = adapter.getSelectedNumber(mSpinner.getSelectedView()); final ContactId remote = ContactUtil.formatContact(phoneNumber); if (LogUtils.isActive) { Log.d(LOGTAG, "shareImage image=" + mFilename + " size=" + mFilesize); } /* Only take persistable permission for content Uris */ takePersistableContentUriPermission(InitiateImageSharing.this, mFile); // Initiate sharing mImageSharing = mImageSharingService.shareImage(remote, mFile); mSharingId = mImageSharing.getSharingId(); // Disable UI mSpinner.setEnabled(false); // Hide buttons mInviteBtn.setVisibility(View.INVISIBLE); mSelectBtn.setVisibility(View.INVISIBLE); mDialBtn.setVisibility(View.INVISIBLE); } catch (RcsServiceNotAvailableException e) { showMessage(R.string.label_service_not_available); } catch (RcsServiceException e) { showExceptionThenExit(e); } } }; mInviteBtn = (Button) findViewById(R.id.invite_btn); mInviteBtn.setOnClickListener(btnInviteListener); mInviteBtn.setEnabled(false); OnClickListener btnSelectListener = new OnClickListener() { public void onClick(View v) { FileUtils.openFile(InitiateImageSharing.this, "image/*", SELECT_IMAGE); } }; mSelectBtn = (Button) findViewById(R.id.select_btn); mSelectBtn.setOnClickListener(btnSelectListener); mSelectBtn.setEnabled(false); OnClickListener btnDialListener = new OnClickListener() { public void onClick(View v) { // get selected phone number ContactListAdapter adapter = (ContactListAdapter) mSpinner.getAdapter(); String phoneNumber = adapter.getSelectedNumber(mSpinner.getSelectedView()); // Initiate a GSM call before to be able to share content Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:".concat(phoneNumber))); if (ActivityCompat.checkSelfPermission(InitiateImageSharing.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return; } startActivity(intent); } }; mDialBtn = (Button) findViewById(R.id.dial_btn); mDialBtn.setOnClickListener(btnDialListener); mDialBtn.setEnabled(false); mStatusView = (TextView) findViewById(R.id.progress_status); mProgressBar = (ProgressBar) findViewById(R.id.progress_bar); mFilenameView = (TextView) findViewById(R.id.uri); updateProgressBar(0, 0); mFilenameView.setText(""); if (adapter == null || adapter.getCount() != 0) { mDialBtn.setEnabled(true); mSelectBtn.setEnabled(true); } mIshListener = new ImageSharingListener() { @Override public void onProgressUpdate(ContactId contact, String sharingId, final long currentSize, final long totalSize) { // Discard event if not for current sharingId if (mSharingId == null || !mSharingId.equals(sharingId)) { return; } mHandler.post(new Runnable() { public void run() { // Display sharing progress updateProgressBar(currentSize, totalSize); } }); } @Override public void onStateChanged(ContactId contact, String sharingId, final ImageSharing.State state, ImageSharing.ReasonCode reasonCode) { if (LogUtils.isActive) { Log.d(LOGTAG, "onStateChanged contact=" + contact + " sharingId=" + sharingId + " state=" + state + " reason=" + reasonCode); } // Discard event if not for current sharingId if (mSharingId == null || !mSharingId.equals(sharingId)) { return; } final String _reasonCode = RiApplication.sImageSharingReasonCodes[reasonCode.toInt()]; final String _state = RiApplication.sImageSharingStates[state.toInt()]; mHandler.post(new Runnable() { public void run() { TextView statusView = (TextView) findViewById(R.id.progress_status); switch (state) { case STARTED: statusView.setText(_state); break; case ABORTED: String msg = getString(R.string.label_sharing_aborted, _reasonCode); mStatusView.setText(msg); showMessageThenExit(msg); break; case REJECTED: msg = getString(R.string.label_sharing_rejected, _reasonCode); mStatusView.setText(msg); showMessageThenExit(msg); break; case FAILED: msg = getString(R.string.label_sharing_failed, _reasonCode); mStatusView.setText(msg); showMessageThenExit(msg); break; case TRANSFERRED: statusView.setText(_state); break; default: statusView.setText(_state); if (LogUtils.isActive) { Log.d(LOGTAG, "onStateChanged " + getString(R.string.label_ish_state_changed, _state, _reasonCode)); } } } }); } @Override public void onDeleted(ContactId contact, Set<String> sharingIds) { if (LogUtils.isActive) { Log.w(LOGTAG, "onDeleted contact=" + contact + " sharingIds=" + sharingIds); } } }; }
From source file:com.android.messaging.ui.UIIntentsImpl.java
@Override public void launchPhoneCallActivity(final Context context, final String phoneNumber, final Point clickPosition) { final Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(UriUtil.SCHEME_TEL + phoneNumber)); final Bundle extras = new Bundle(); extras.putParcelable(CALL_TARGET_CLICK_KEY, clickPosition); intent.putExtra(CALL_TARGET_CLICK_EXTRA_KEY, extras); startExternalActivity(context, intent); }
From source file:com.ericsun.duom.Framework.Activity.BaseActivity.java
public void showPhoneDialog(final String phoneNumber) { myDialog = new CustomDialog(ct); myDialog.setTitle(phoneNumber);/* w w w . j a v a 2s . com*/ // myDialog.setPositiveTitle("?"); myDialog.setOnPositiveListener(new OnClickListener() { @Override public void onClick(View v) { if (myDialog != null) { Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)); if (ActivityCompat.checkSelfPermission(ct, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return; } ct.startActivity(intent); myDialog.dismiss(); myDialog = null; } } }); // ? myDialog.setOnNegativeListener(new OnClickListener() { @Override public void onClick(View v) { if (myDialog != null) { myDialog.dismiss(); myDialog = null; } } }); myDialog.show(); }
From source file:com.silentcircle.contacts.list.ShortcutIntentBuilder.java
private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData, String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) { Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); Bitmap bitmap = null;/* w ww.j a v a 2s.c o m*/ Uri phoneUri = null; if (Intent.ACTION_CALL.equals(shortcutAction)) { // Make the URI a direct tel: URI so that it will always continue to work phoneUri = Uri.fromParts(Constants.SCHEME_TEL, phoneNumber, null); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.badge_action_call); // } else { // phoneUri = Uri.fromParts(Constants.SCHEME_SMSTO, phoneNumber, null); // bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, // R.drawable.badge_action_sms); } Intent shortcutIntent = new Intent(shortcutAction, phoneUri); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName); mListener.onShortcutIntentCreated(uri, intent); }
From source file:net.kourlas.voipms_sms.activities.ConversationActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { switch (item.getItemId()) { case R.id.call_button: Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + contact)); startActivity(intent);/*from www. jav a2s . co m*/ return true; case R.id.delete_button: Conversation conversation = database.getConversation(preferences.getDid(), contact); if (conversation.getMessages().length == 0) { NavUtils.navigateUpFromSameTask(this); } else { List<Long> databaseIds = new ArrayList<>(); for (int i = 0; i < adapter.getItemCount(); i++) { if (adapter.getItem(i).getDatabaseId() != null) { databaseIds.add(adapter.getItem(i).getDatabaseId()); } } Long[] databaseIdsArray = new Long[databaseIds.size()]; databaseIds.toArray(databaseIdsArray); deleteMessages(databaseIdsArray); } return true; } } return super.onOptionsItemSelected(item); }
From source file:com.android.contacts.common.list.ShortcutIntentBuilder.java
private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData, String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) { Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); Bitmap bitmap;/*from w w w . j a v a 2s . c o m*/ Uri phoneUri; 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); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_call); } else { phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_message_24dp); } Intent shortcutIntent = new Intent(shortcutAction, phoneUri); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } if (TextUtils.equals(shortcutAction, Intent.ACTION_CALL)) { intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.call_by_shortcut, displayName)); } else if (TextUtils.equals(shortcutAction, Intent.ACTION_SENDTO)) { intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.sms_by_shortcut, displayName)); } mListener.onShortcutIntentCreated(uri, intent); }
From source file:com.polyvi.xface.extension.telephony.XTelephonyExt.java
/** * ???//from w w w . ja v a2 s . co m * * @param[in] phoneNumber ???? * @return ??? */ private boolean initiateVoiceCall(String phoneNumber) { try { if (isLegalPhoneNum(phoneNumber)) { Intent intent = new Intent(Intent.ACTION_CALL); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(WebView.SCHEME_TEL + phoneNumber)); mContext.startActivity(intent); return true; } } catch (ActivityNotFoundException e) { XLog.e(CLASS_NAME, e.toString()); } catch (SecurityException e) { XLog.e(CLASS_NAME, e.toString()); } return false; }
From source file:com.mobileglobe.android.customdialer.common.list.ShortcutIntentBuilder.java
private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData, String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) { Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); Bitmap bitmap;//from ww w.j a va 2 s . c om Uri phoneUri; 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); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_call); } else { phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null); bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_message_24dp_mirrored); } Intent shortcutIntent = new Intent(shortcutAction, phoneUri); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } if (TextUtils.equals(shortcutAction, Intent.ACTION_CALL)) { intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.call_by_shortcut, displayName)); } else if (TextUtils.equals(shortcutAction, Intent.ACTION_SENDTO)) { intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.sms_by_shortcut, displayName)); } mListener.onShortcutIntentCreated(uri, intent); }
From source file:com.polyvi.xface.extension.XTelephonyExt.java
/** * ???//from w w w.j a va 2 s . c o m * * @param[in] phoneNumber ???? * @return ??? * */ private boolean initiateVoiceCall(String phoneNumber) { try { if (isLegalPhoneNum(phoneNumber)) { Intent intent = new Intent(Intent.ACTION_CALL); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(WebView.SCHEME_TEL + phoneNumber)); getContext().startActivity(intent); return true; } } catch (ActivityNotFoundException e) { XLog.e(CLASS_NAME, e.toString()); } catch (SecurityException e) { XLog.e(CLASS_NAME, e.toString()); } return false; }