首页 > 代码库 > 在Launcher的主菜单中隐藏某个应用removePackage

在Launcher的主菜单中隐藏某个应用removePackage

在package/apps/Launcher3/src/com/android/launcher3/LauncherModel.java中的private void loadAllApps() {}函数中的mBgAllAppsList.reorderApplist();之前添加如下:

     // ZJ Add START
               mBgAllAppsList.removePackage("com.mediatek.filemanager");
               mBgAllAppsList.removePackage("com.android.chrome");
               mBgAllAppsList.removePackage("com.android.providers.downloads.ui");
               mBgAllAppsList.removePackage("com.android.deskclock");
               mBgAllAppsList.removePackage("com.android.email");
               mBgAllAppsList.removePackage("com.google.android.apps.maps");
               mBgAllAppsList.removePackage("com.google.android.gm");
               mBgAllAppsList.removePackage("com.android.soundrecorder");
               mBgAllAppsList.removePackage("com.mediatek.FMRadio");
               mBgAllAppsList.removePackage("com.google.android.inputmethod.korean");
               //  ZJ Add END

            mBgAllAppsList.reorderApplist(); 

mBgAllAppList是类AllAppList的对象,可以看下AllAppList这个类的内容:

/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.android.launcher3;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Xml;

import com.android.internal.util.XmlUtils;
import com.android.launcher3.R;

import com.mediatek.launcher3.ext.LauncherLog;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

/**
* Stores the list of all applications for the all apps view.
*/
class AllAppsList {
    private static final String TAG = "AllAppsList";
   
    /// M: add for top packages.
    private static final String TAG_TOPPACKAGES = "toppackages";
    private static final String WIFI_SETTINGPKGNAME = "com.android.settings";
    private static final String WIFI_SETTINGCLASSNAME = "com.android.settings.Settings$WifiSettingsActivity";

    private static final boolean DEBUG_LOADERS_REORDER = false;
    public static final int DEFAULT_APPLICATIONS_NUMBER = 42;

    /** The list off all apps. */
    public ArrayList<AppInfo> data =
            http://www.mamicode.com/new ArrayList(DEFAULT_APPLICATIONS_NUMBER);>

在Launcher的主菜单中隐藏某个应用removePackage