2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings;
19 import android.app.LauncherActivity;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.view.View;
23 import android.widget.ListView;
25 public class CreateShortcut extends LauncherActivity {
28 protected Intent getTargetIntent() {
29 Intent targetIntent = new Intent(Intent.ACTION_MAIN, null);
30 targetIntent.addCategory("com.android.settings.SHORTCUT");
31 targetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
36 protected void onListItemClick(ListView l, View v, int position, long id) {
37 Intent shortcutIntent = intentForPosition(position);
38 shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
39 Intent intent = new Intent();
40 intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
41 Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher_settings));
42 intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
43 intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, itemForPosition(position).label);
44 setResult(RESULT_OK, intent);
49 protected boolean onEvaluateShowIcons() {