1 /** 2 * Copyright (c) 2018 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.example.android.multidisplay.launcher; 18 19 import android.content.ComponentName; 20 import android.content.Intent; 21 import android.content.pm.PackageManager; 22 import android.content.pm.ResolveInfo; 23 import android.graphics.drawable.Drawable; 24 25 /** An entry that represents a single activity that can be launched. */ 26 public class AppEntry { 27 28 private String mLabel; 29 private Drawable mIcon; 30 private Intent mLaunchIntent; 31 AppEntry(ResolveInfo info, PackageManager packageManager)32 AppEntry(ResolveInfo info, PackageManager packageManager) { 33 mLabel = info.loadLabel(packageManager).toString(); 34 mIcon = info.loadIcon(packageManager); 35 mLaunchIntent = new Intent(); 36 mLaunchIntent.setComponent(new ComponentName(info.activityInfo.packageName, 37 info.activityInfo.name)); 38 } 39 getLabel()40 String getLabel() { 41 return mLabel; 42 } 43 getIcon()44 Drawable getIcon() { 45 return mIcon; 46 } 47 getLaunchIntent()48 Intent getLaunchIntent() { return mLaunchIntent; } 49 getComponentName()50 ComponentName getComponentName() { 51 return mLaunchIntent.getComponent(); 52 } 53 54 @Override toString()55 public String toString() { 56 return mLabel; 57 } 58 } 59