/talkingdialer/src/com/google/marvin/talkingdialer/TalkingDialer.java

http://eyes-free.googlecode.com/ · Java · 56 lines · 28 code · 8 blank · 20 comment · 4 complexity · 6626d823c29fdf0e80ec960b86a70462 MD5 · raw file

  1. /*
  2. * Copyright (C) 2008 Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.google.marvin.talkingdialer;
  17. import android.app.Activity;
  18. import android.content.Intent;
  19. import android.net.Uri;
  20. /**
  21. * Talking dialer for eyes-free dialing
  22. *
  23. * @author clchen@google.com (Charles L. Chen)
  24. */
  25. public class TalkingDialer extends Activity {
  26. private final int reqCode = 1;
  27. @Override
  28. public void onResume() {
  29. super.onResume();
  30. setContentView(R.layout.main);
  31. Intent intent = new Intent(this, SlideDial.class);
  32. startActivityForResult(intent, reqCode);
  33. }
  34. @Override
  35. public void onActivityResult(int requestCode, int resultCode, Intent data) {
  36. if (requestCode == reqCode) {
  37. if (resultCode == Activity.RESULT_CANCELED) {
  38. finish();
  39. return;
  40. }
  41. String phoneNumber = data.getStringExtra("number");
  42. Uri phoneNumberURI = Uri.parse("tel:" + Uri.encode(phoneNumber));
  43. Intent intent = new Intent(Intent.ACTION_CALL, phoneNumberURI);
  44. startActivity(intent);
  45. finish();
  46. }
  47. }
  48. }