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.dashihui.afford.ui.activity.AtyFragmentServerDetail.java
@Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.ibtnBack: onBackPressed();/*from w w w .j ava 2 s. c om*/ break; case R.id.top_btn_right: String phone = AffordApp.getInstance().getEntityLocation().getSTORE().getTEL(); LogUtils.e("onClick===========phone==========>" + phone); Intent intent = new Intent(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone))); startActivity(intent); break; default: break; } }
From source file:com.z.stproperty.PropertyDetailFragment.java
/** * onClick :: OnClickListener//from www . j ava 2s . co m * * Is common on-click listener for all the buttons and images in home screen * This is grouped into single listener to make easier to alter the code and reduce the * line of code. * * This will check the View ID to match with the predefined View-ID to identify * which view is clicked * * Based on the view id this will perform different functionalities */ private void performClickAction(View v) { try { switch (v.getId()) { case R.id.LoanCalculator: Intent calIntent = new Intent(getActivity(), LoanCalculator.class); calIntent.putExtra("price", price); startActivity(calIntent); break; case R.id.AgentMobile: String url = "tel:" + mobileNoStr; url = url.replace("+65-", ""); Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse(url)); startActivity(callIntent); break; case R.id.SendEmailBtn: String text = "I'm interested in your property advertised on STProperty\n\n" + "PROPERTY TITLE:" + title + "\n" + "PRICE:" + price + "\n\nClick on the following link to view more details about the property\n\n" + prurl; Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { agentEmail }); intent.putExtra(Intent.EXTRA_SUBJECT, "Enquiry"); intent.putExtra(Intent.EXTRA_TEXT, text); SharedFunction.postAnalytics(PropertyDetailFragment.this.getActivity(), "Lead", "Successful Email Enquiry", title); startActivity(Intent.createChooser(intent, "")); break; /**case R.id.SendEnquiryBtn: Intent enqInt = new Intent(getActivity(), SaleEnquiry.class); enqInt.putExtra("propertyId", detailsJson.getString("id")); enqInt.putExtra("agentId", detailsJson.getJSONObject("seller_info").getString("agent_cea_reg_no")); startActivity(enqInt); break;*/ default: break; } } catch (Exception e) { Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage(), e); } }
From source file:sintef.android.gravity.AlarmFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (getView() == null) return;//from w w w . j av a 2 s . c o m ButterKnife.inject(this, getView()); mAlarmView.setOnStopListener(new AlarmView.OnStopListener() { @Override public void onStop() { if (sVibrator != null) sVibrator.cancel(); EventBus.getDefault().post(EventTypes.ALARM_STOPPED); } }); mAlarmView.setOnAlarmListener(new AlarmView.OnAlarmListener() { @Override public void onAlarm() { EventBus.getDefault().post(EventTypes.STOP_ALARM); Log.w("Alarm", "notifying EMHT"); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... voids) { try { String data = ""; data += "type=fall&"; data += "callee.phoneNumber=" + getResources().getString(R.string.callee_phone_number) + "&"; data += "callee.name=" + getResources().getString(R.string.callee_name) + "&"; data += "callee.address=" + getResources().getString(R.string.callee_address); Log.w("Alarm", "postdata is: " + data); URL url = new URL(getResources().getString(R.string.server_address) + "/alarm"); Log.w("Alarm", "emht server url is: " + url.toString()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setInstanceFollowRedirects(false); connection.setRequestMethod("POST"); BufferedWriter bw = null; try { bw = new BufferedWriter( new OutputStreamWriter(connection.getOutputStream(), "UTF-8")); bw.write(data); bw.flush(); } finally { if (bw != null) bw.close(); } Log.w("Alarm", "connection response code is: " + connection.getResponseCode()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }.execute(); Log.w("Alarm", "calling nextofkin"); sManager.listen(sPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); sCallFromApp = true; Intent intent = new Intent(Intent.ACTION_CALL); intent.setData( Uri.parse("tel:" + PreferencesHelper.getString(Constants.PREFS_NEXT_OF_KIN_TELEPHONE))); getActivity().startActivity(intent); } }); EventBus.getDefault().register(this); boolean start_alarm = getArguments().getBoolean(AlarmService.ALARM_STARTED); if (start_alarm) mAlarmView.startAlarm(); }
From source file:com.ferid.app.frequentcontacts.MainActivity.java
/** * Call the selected contact//from w w w. j a va2 s . c om */ private void callContact() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED) { //if permission is already granted Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + contact.getNumber())); startActivity(callIntent); } }
From source file:org.linphone.LinphoneService.java
void tryTogetLastRequest() { new Thread() { public void run() { while (receiveall) { try { String str = YaoqingNetworkUtils.noticegetLastRequestResultForHttpGet(); JSONObject jsonObject = new JSONObject(str.toString()); String state = jsonObject.getString("ispass"); String msg = jsonObject.getString("phone"); String num = jsonObject.getString("phone"); Log.i(TAG, "state=" + state); Log.i(TAG, "msg=" + msg); if (state.equals("Y")) { Intent intent = new Intent(Intent.ACTION_CALL, Uri // .parse("tel:" + "13581606890")); .parse("tel:" + "10086")); startActivity(intent); }/*from w w w. j a va 2s . co m*/ } catch (ClientProtocolException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } } }; }.start(); }
From source file:com.pk.ubulance.Activity.DisplayDriverActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_driver); ButterKnife.bind(this); mContext = this; getSupportActionBar().setDisplayHomeAsUpEnabled(true); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.activity_driver_screen); mDialog = ProgressDialog.show(this, "", "Booking Ubulance, Please wait...", true); // callIntent = new Intent(Intent.ACTION_CALL); GetLocation getLocation = new GetLocation(this); if (getLocation.canGetLocation()) { mStartLatitude = Double.toString(getLocation.getLatitude()); mStartLongitude = Double.toString(getLocation.getLongitude()); mUserAddressTV/* www . j a va2 s .c o m*/ .setText(getLocationName(mContext, getLocation.getLatitude(), getLocation.getLongitude())); mShowUserLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String strUri = "http://maps.google.com/maps?q=loc:" + getLocation.getLatitude() + "," + getLocation.getLongitude() + " (" + "You are here" + ")"; Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri)); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(intent); } }); } else { getLocation.showSettingsAlert(); } Intent intent = this.getIntent(); Double mEndLatitude = intent.getDoubleExtra("mEndLatitude", 0.0); Double mEndLongitude = intent.getDoubleExtra("mEndLongitude", 0.0); mHospitalAddressTV.setText(intent.getStringExtra("vicinity")); mShowHospitalLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String strUri = "http://maps.google.com/maps?q=" + mHospitalAddressTV.getText().toString() + " (" + "Hospital" + ")"; Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri)); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(intent); } }); if (mEndLatitude != 0.0 || mEndLongitude != 0.0) { this.mEndLatitude = Double.toString(mEndLatitude); this.mEndLongitude = Double.toString(mEndLongitude); } if (isNetworkAvailable()) { UberAPI uberAPI = new UberAPI(); mWorkOnProcess = true; try { uberAPI.callUbulance(this, mStartLatitude, mStartLongitude, this.mEndLatitude, this.mEndLongitude, new ServerCallBack() { @Override public void onSuccess(Object result) throws JSONException { final JSONObject finalResult = (JSONObject) result; String product_id = finalResult.getString("product_id"); Log.d("Ubulance", "[FINAL] Product Id: " + product_id); String request_id = finalResult.getString("request_id"); Log.d("Ubulance", "[FINAL] Product Id: " + request_id); mStatusTV.setText("Status: " + finalResult.getString("status")); final JSONObject pickup = finalResult.getJSONObject("pickup"); mEtaTV.setText("ETA: " + pickup.getString("eta") + "min"); final JSONObject driver = finalResult.getJSONObject("driver"); mDriverNameTV.setText("Driver: " + driver.getString("name")); mDriverPhoneTV.setVisibility(View.VISIBLE); mDriverPhoneTV.setText("Call: " + driver.getString("phone_number")); mCallDriver.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_CALL); try { intent.setData(Uri.parse("tel:" + driver.getString("phone_number"))); } catch (JSONException e) { e.printStackTrace(); } if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } startActivity(intent); } }); mDriverRatingTV.setText("Rating: " + driver.getString("rating")); final JSONObject vehicle = finalResult.getJSONObject("vehicle"); displayDriverImage(mContext, driver.getString("picture_url")); mToggleIV.setOnClickListener(new View.OnClickListener() { Boolean toggle = true; @Override public void onClick(View view) { try { if (toggle) { Glide.with(mContext).load(vehicle.getString("picture_url")) .into(mToggleIV); toggle = false; } else { displayDriverImage(mContext, driver.getString("picture_url")); toggle = true; } } catch (JSONException e) { e.printStackTrace(); } } }); mVehicleMakeTV.setText("Make: " + vehicle.getString("make")); mVehicleModelTV.setText("Model: " + vehicle.getString("model")); mVehiclePlateTV.setText("Licence Plate: " + vehicle.getString("license_plate")); mWorkOnProcess = false; mDialog.dismiss(); } @Override public void onFailure(Boolean bool) { mWorkOnProcess = false; } }); } catch (JSONException e) { e.printStackTrace(); } } else { Snackbar.make(mCoordinatorLayout, "No Internet. Please dial 911, if its emergency or try again later", Snackbar.LENGTH_LONG).show(); } }
From source file:texus.autozoneuaenew.fragments.FragmentProductDetails.java
private void dialNumber(String number) { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED) { String uri = "tel:" + number; Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse(uri));//from w ww. j ava 2 s . c o m getActivity().startActivity(intent); } else { ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.CALL_PHONE }, 1242); } }
From source file:cx.ring.fragments.SmartListFragment.java
@Override public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.smartlist_menu, menu); mSearchMenuItem = menu.findItem(R.id.menu_contact_search); mDialpadMenuItem = menu.findItem(R.id.menu_contact_dial); MenuItemCompat.setOnActionExpandListener(mSearchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override/*from w w w .j a va 2 s. c o m*/ public boolean onMenuItemActionCollapse(MenuItem item) { mDialpadMenuItem.setVisible(false); displayFloatingActionButtonWithDelay(true, 50); setOverflowMenuVisible(menu, true); setLoading(false); return true; } @Override public boolean onMenuItemActionExpand(MenuItem item) { mDialpadMenuItem.setVisible(true); displayFloatingActionButtonWithDelay(false, 0); setOverflowMenuVisible(menu, false); setLoading(false); return true; } }); mSearchView = (SearchView) mSearchMenuItem.getActionView(); mSearchView.setOnQueryTextListener(this); mSearchView.setQueryHint(getString(R.string.searchbar_hint)); mSearchView.setLayoutParams( new Toolbar.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, Toolbar.LayoutParams.MATCH_PARENT)); mSearchView.setImeOptions(EditorInfo.IME_ACTION_GO); Intent i = getActivity().getIntent(); switch (i.getAction()) { case Intent.ACTION_VIEW: case Intent.ACTION_CALL: mSearchView.setQuery(i.getDataString(), true); break; case Intent.ACTION_DIAL: mSearchMenuItem.expandActionView(); mSearchView.setQuery(i.getDataString(), false); break; } }
From source file:com.jungle.base.utils.MiscUtils.java
public static boolean callPhoneNumber(Context context, String phoneNumber) { Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try {/*from w ww. j ava 2 s . com*/ context.startActivity(intent); } catch (ActivityNotFoundException e) { e.printStackTrace(); return false; } return true; }
From source file:com.appteam.nimbus.activity.homeActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_logout) { personalData.SaveData(false);/*from www .j ava 2 s.c o m*/ Intent launch_logout = new Intent(homeActivity.this, Login.class); launch_logout.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launch_logout.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); launch_logout.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(launch_logout); finish(); return true; } else if (id == R.id.action_leaderboard) { startActivity(new Intent(homeActivity.this, Leaderboard.class)); return true; } else if (id == R.id.action_important_contact) { CharSequence name[] = { "Ankush Sharma\n(Discipline Secretary)", "Rishabh Kumar\n(Discipline Joint Secretary)", "Kumud Jindal\n(Discipline Joint Secretary)", }; final CharSequence number[] = { "9736688292", "8627090570", "9882263949" }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(android.R.drawable.ic_menu_call); builder.setTitle("Emergency Contact"); builder.setItems(name, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:+91" + number[i])); startActivity(intent); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); } return super.onOptionsItemSelected(item); }