/talkingdialer/src/com/google/marvin/talkingdialer/TalkingDialer.java
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 17package com.google.marvin.talkingdialer; 18 19import android.app.Activity; 20import android.content.Intent; 21import android.net.Uri; 22 23/** 24 * Talking dialer for eyes-free dialing 25 * 26 * @author clchen@google.com (Charles L. Chen) 27 */ 28public class TalkingDialer extends Activity { 29 30 private final int reqCode = 1; 31 32 @Override 33 public void onResume() { 34 super.onResume(); 35 setContentView(R.layout.main); 36 Intent intent = new Intent(this, SlideDial.class); 37 startActivityForResult(intent, reqCode); 38 } 39 40 @Override 41 public void onActivityResult(int requestCode, int resultCode, Intent data) { 42 if (requestCode == reqCode) { 43 if (resultCode == Activity.RESULT_CANCELED) { 44 finish(); 45 return; 46 } 47 String phoneNumber = data.getStringExtra("number"); 48 Uri phoneNumberURI = Uri.parse("tel:" + Uri.encode(phoneNumber)); 49 50 Intent intent = new Intent(Intent.ACTION_CALL, phoneNumberURI); 51 startActivity(intent); 52 finish(); 53 } 54 } 55 56}