• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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.tv.settings.resolver;
18 
19 import android.content.Intent;
20 import android.os.Bundle;
21 import android.os.Parcelable;
22 import android.util.Log;
23 
24 public class ChooserActivity extends ResolverActivity {
25     @Override
onCreate(Bundle savedInstanceState)26     protected void onCreate(Bundle savedInstanceState) {
27         Intent intent = getIntent();
28         Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
29         if (!(targetParcelable instanceof Intent)) {
30             Log.w("ChooseActivity", "Target is not an intent: " + targetParcelable);
31             finish();
32             return;
33         }
34         Intent target = (Intent)targetParcelable;
35         CharSequence title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE);
36         if (title == null) {
37             title = "Chooser";
38         }
39         Parcelable[] pa = intent.getParcelableArrayExtra(Intent.EXTRA_INITIAL_INTENTS);
40         Intent[] initialIntents = null;
41         if (pa != null) {
42             initialIntents = new Intent[pa.length];
43             for (int i=0; i<pa.length; i++) {
44                 if (!(pa[i] instanceof Intent)) {
45                     Log.w("ChooseActivity", "Initial intent #" + i
46                             + " not an Intent: " + pa[i]);
47                     finish();
48                     return;
49                 }
50                 initialIntents[i] = (Intent)pa[i];
51             }
52         }
53         super.onCreate(savedInstanceState, target, title, initialIntents, null, false);
54     }
55 }
56