blob: 1eda373477bb56ed2b73d222f9184d218dd27898 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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
17package com.android.internal.app;
18
19import android.content.Intent;
20import android.os.Bundle;
Dianne Hackborneb034652009-09-07 00:49:58 -070021import android.os.Parcelable;
22import android.util.Log;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023
24public class ChooserActivity extends ResolverActivity {
25 @Override
26 protected void onCreate(Bundle savedInstanceState) {
27 Intent intent = getIntent();
Dianne Hackborneb034652009-09-07 00:49:58 -070028 Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
29 if (!(targetParcelable instanceof Intent)) {
Christopher Tate9d6376a2014-02-12 13:14:10 -080030 Log.w("ChooserActivity", "Target is not an intent: " + targetParcelable);
Dianne Hackborneb034652009-09-07 00:49:58 -070031 finish();
Christopher Tate9d6376a2014-02-12 13:14:10 -080032 super.onCreate(null);
Dianne Hackborneb034652009-09-07 00:49:58 -070033 return;
34 }
35 Intent target = (Intent)targetParcelable;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036 CharSequence title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE);
37 if (title == null) {
38 title = getResources().getText(com.android.internal.R.string.chooseActivity);
39 }
Dianne Hackborneb034652009-09-07 00:49:58 -070040 Parcelable[] pa = intent.getParcelableArrayExtra(Intent.EXTRA_INITIAL_INTENTS);
41 Intent[] initialIntents = null;
42 if (pa != null) {
43 initialIntents = new Intent[pa.length];
44 for (int i=0; i<pa.length; i++) {
45 if (!(pa[i] instanceof Intent)) {
Christopher Tate9d6376a2014-02-12 13:14:10 -080046 Log.w("ChooserActivity", "Initial intent #" + i
Dianne Hackborneb034652009-09-07 00:49:58 -070047 + " not an Intent: " + pa[i]);
48 finish();
Christopher Tate9d6376a2014-02-12 13:14:10 -080049 super.onCreate(null);
Dianne Hackborneb034652009-09-07 00:49:58 -070050 return;
51 }
52 initialIntents[i] = (Intent)pa[i];
53 }
54 }
Jeff Hamiltond88e9aa2011-01-24 14:53:00 -060055 super.onCreate(savedInstanceState, target, title, initialIntents, null, false);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056 }
57}