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;
}
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;
}
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;
}
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();
}
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;
}
Aggregations