Search in sources :

Example 6 with ComponentName

use of android.content.ComponentName in project ADWLauncher2 by boombuler.

the class ActivityPickerActivity method onChildClick.

@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    ActivityInfo info = (ActivityInfo) getExpandableListAdapter().getChild(groupPosition, childPosition);
    Intent intent = new Intent();
    intent.setComponent(new ComponentName(info.applicationInfo.packageName, info.name));
    Intent mReturnData = new Intent();
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    mReturnData.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
    // Set the name of the activity
    mReturnData.putExtra(Intent.EXTRA_SHORTCUT_NAME, info.loadLabel(mPackageManager));
    ShortcutIconResource iconResource = new ShortcutIconResource();
    iconResource.packageName = info.packageName;
    try {
        Resources resources = mPackageManager.getResourcesForApplication(iconResource.packageName);
        iconResource.resourceName = resources.getResourceName(info.getIconResource());
        mReturnData.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
    } catch (NameNotFoundException e) {
    } catch (Resources.NotFoundException e) {
    }
    setResult(RESULT_OK, mReturnData);
    finish();
    return true;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ShortcutIconResource(android.content.Intent.ShortcutIconResource) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Resources(android.content.res.Resources)

Example 7 with ComponentName

use of android.content.ComponentName in project ADWLauncher2 by boombuler.

the class AllApps2D method findAppByComponent.

private static int findAppByComponent(ArrayList<IconItemInfo> list, ShortcutInfo item) {
    ComponentName component = item.intent.getComponent();
    if (component == null)
        return -1;
    final int N = list.size();
    for (int i = 0; i < N; i++) {
        IconItemInfo curItm = list.get(i);
        if (curItm instanceof ShortcutInfo) {
            ShortcutInfo x = (ShortcutInfo) curItm;
            if (component.equals(x.intent.getComponent())) {
                return i;
            }
        }
    }
    return -1;
}
Also used : ComponentName(android.content.ComponentName)

Example 8 with ComponentName

use of android.content.ComponentName in project ADWLauncher2 by boombuler.

the class AllAppsList method findActivity.

private static ShortcutInfo findActivity(ArrayList<ShortcutInfo> apps, ComponentName component) {
    if (component == null)
        return null;
    final int N = apps.size();
    for (int i = 0; i < N; i++) {
        final ShortcutInfo info = apps.get(i);
        ComponentName cn = info.intent.getComponent();
        if (component.equals(cn)) {
            return info;
        }
    }
    return null;
}
Also used : ComponentName(android.content.ComponentName)

Example 9 with ComponentName

use of android.content.ComponentName in project ADWLauncher2 by boombuler.

the class AllAppsList method removeComponentNames.

/**
     * Remove the apps for the given list of component names
     */
public void removeComponentNames(String[] componentNames) {
    final List<ShortcutInfo> data = this.data;
    for (int i = data.size() - 1; i >= 0; i--) {
        ShortcutInfo info = data.get(i);
        final ComponentName component = info.intent.getComponent();
        if (component != null) {
            final String cname = component.flattenToString();
            if (AppDB.arrayContains(componentNames, cname)) {
                removed.add(info);
                data.remove(i);
            }
        }
    }
    // This is more aggressive than it needs to be.
    mIconCache.flush();
}
Also used : ComponentName(android.content.ComponentName)

Example 10 with ComponentName

use of android.content.ComponentName in project VirtualApp by asLody.

the class VirtualCore method resolveActivityInfo.

public synchronized ActivityInfo resolveActivityInfo(Intent intent, int userId) {
    ActivityInfo activityInfo = null;
    if (intent.getComponent() == null) {
        ResolveInfo resolveInfo = VPackageManager.get().resolveIntent(intent, intent.getType(), 0, userId);
        if (resolveInfo != null && resolveInfo.activityInfo != null) {
            activityInfo = resolveInfo.activityInfo;
            intent.setClassName(activityInfo.packageName, activityInfo.name);
        }
    } else {
        activityInfo = resolveActivityInfo(intent.getComponent(), userId);
    }
    if (activityInfo != null) {
        if (activityInfo.targetActivity != null) {
            ComponentName componentName = new ComponentName(activityInfo.packageName, activityInfo.targetActivity);
            activityInfo = VPackageManager.get().getActivityInfo(componentName, 0, userId);
            intent.setComponent(componentName);
        }
    }
    return activityInfo;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) ComponentName(android.content.ComponentName)

Aggregations

ComponentName (android.content.ComponentName)2548 Intent (android.content.Intent)959 ResolveInfo (android.content.pm.ResolveInfo)375 RemoteException (android.os.RemoteException)317 PackageManager (android.content.pm.PackageManager)269 PendingIntent (android.app.PendingIntent)252 ActivityInfo (android.content.pm.ActivityInfo)243 ArrayList (java.util.ArrayList)242 ShortcutInfo (android.content.pm.ShortcutInfo)152 Point (android.graphics.Point)145 Bundle (android.os.Bundle)139 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)132 IBinder (android.os.IBinder)128 IOException (java.io.IOException)125 ServiceConnection (android.content.ServiceConnection)96 ServiceInfo (android.content.pm.ServiceInfo)96 UserHandle (android.os.UserHandle)86 ArraySet (android.util.ArraySet)73 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Uri (android.net.Uri)68