1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of 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, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.contacts; 18 19 import com.android.contacts.interactions.PhoneNumberInteraction; 20 21 import android.app.Dialog; 22 import android.content.DialogInterface; 23 import android.content.DialogInterface.OnDismissListener; 24 import android.content.Intent; 25 import android.net.Uri; 26 import android.os.Bundle; 27 import android.provider.ContactsContract.Contacts; 28 29 /** 30 * An interstitial activity used when the user selects a QSB search suggestion using 31 * a call button. 32 */ 33 public class CallContactActivity extends ContactsActivity implements OnDismissListener { 34 35 @Override 36 protected void onCreate(Bundle savedInstanceState) { 37 super.onCreate(savedInstanceState); 38 39 Uri contactUri = getIntent().getData(); 40 if (contactUri == null) { 41 finish(); 42 } 43 44 // If this method is being invoked with a saved state, rely on Activity 45 // to restore it 46 if (savedInstanceState != null) { 47 return; 48 } 49 50 if (Contacts.CONTENT_ITEM_TYPE.equals(getContentResolver().getType(contactUri))) { 51 PhoneNumberInteraction.startInteractionForPhoneCall(this, contactUri); 52 } else { 53 startActivity(new Intent(Intent.ACTION_CALL_PRIVILEGED, contactUri)); 54 finish(); 55 } 56 } 57 58 @Override 59 public void onDismiss(DialogInterface dialog) { 60 if (!isChangingConfigurations()) { 61 finish(); 62 } 63 } 64 } 65