Search in sources :

Example 6 with ResolveInfo

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();
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) ComponentName(android.content.ComponentName)

Example 7 with ResolveInfo

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);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 8 with ResolveInfo

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();
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent)

Example 9 with ResolveInfo

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);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 10 with ResolveInfo

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) ComponentName(android.content.ComponentName) MenuItem(com.actionbarsherlock.view.MenuItem)

Aggregations

ResolveInfo (android.content.pm.ResolveInfo)2316 Intent (android.content.Intent)1476 PackageManager (android.content.pm.PackageManager)875 ComponentName (android.content.ComponentName)637 ArrayList (java.util.ArrayList)515 ActivityInfo (android.content.pm.ActivityInfo)360 Test (org.junit.Test)282 ServiceInfo (android.content.pm.ServiceInfo)203 PendingIntent (android.app.PendingIntent)183 ApplicationInfo (android.content.pm.ApplicationInfo)178 RemoteException (android.os.RemoteException)170 Context (android.content.Context)101 Bundle (android.os.Bundle)97 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)81 IOException (java.io.IOException)78 PackageInfo (android.content.pm.PackageInfo)68 HashSet (java.util.HashSet)65 HashMap (java.util.HashMap)63 ActivityNotFoundException (android.content.ActivityNotFoundException)59 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)58