use of android.content.pm.ResolveInfo in project cw-omnibus by commonsguy.
the class MainActivity method onListItemClick.
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
ResolveInfo launchable = adapter.getItem(position);
ActivityInfo activity = launchable.activityInfo;
ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
PreferenceManager.getDefaultSharedPreferences(this).edit().putString(FreecarTileService.PREF_TO_LAUNCH, name.flattenToString()).apply();
Toast.makeText(this, R.string.msg_saved, Toast.LENGTH_LONG).show();
finish();
}
use of android.content.pm.ResolveInfo in project cw-omnibus by commonsguy.
the class Launchalot method onListItemClick.
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
ResolveInfo launchable = adapter.getItem(position);
ActivityInfo activity = launchable.activityInfo;
ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(name);
startActivity(i);
}
use of android.content.pm.ResolveInfo in project cw-omnibus by commonsguy.
the class ResolveActivityDemoActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PackageManager mgr = getPackageManager();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://commonsware.com"));
ResolveInfo ri = mgr.resolveActivity(i, PackageManager.MATCH_DEFAULT_ONLY);
Toast.makeText(this, ri.loadLabel(mgr), Toast.LENGTH_LONG).show();
startActivity(i);
finish();
}
use of android.content.pm.ResolveInfo in project cw-omnibus by commonsguy.
the class StopReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context.getString(R.string.service_action)).setPackage(context.getPackageName());
PackageManager mgr = context.getPackageManager();
for (ResolveInfo ri : mgr.queryIntentServices(i, 0)) {
ComponentName cn = new ComponentName(ri.serviceInfo.applicationInfo.packageName, ri.serviceInfo.name);
Intent stop = new Intent().setComponent(cn);
context.stopService(stop);
}
}
use of android.content.pm.ResolveInfo in project cw-omnibus by commonsguy.
the class ActionMenu method addIntentOptions.
public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) {
PackageManager pm = mContext.getPackageManager();
final List<ResolveInfo> lri = pm.queryIntentActivityOptions(caller, specifics, intent, 0);
final int N = lri != null ? lri.size() : 0;
if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
removeGroup(groupId);
}
for (int i = 0; i < N; i++) {
final ResolveInfo ri = lri.get(i);
Intent rintent = new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName, ri.activityInfo.name));
final MenuItem item = add(groupId, itemId, order, ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
if (outSpecificItems != null && ri.specificIndex >= 0) {
outSpecificItems[ri.specificIndex] = item;
}
}
return N;
}
Aggregations