android.content.pm.ResolveInfo Java Examples

The following examples show how to use android.content.pm.ResolveInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PulltorefreshSwipeTest.java    From android-common-utils with Apache License 2.0 6 votes vote down vote up
private void open(ApplicationInfo item) {
    // open app
    Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
    resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    resolveIntent.setPackage(item.packageName);
    List<ResolveInfo> resolveInfoList = getPackageManager().queryIntentActivities(resolveIntent, 0);
    if (resolveInfoList != null && resolveInfoList.size() > 0) {
        ResolveInfo resolveInfo = resolveInfoList.get(0);
        String activityPackageName = resolveInfo.activityInfo.packageName;
        String className = resolveInfo.activityInfo.name;

        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        ComponentName componentName = new ComponentName(activityPackageName, className);

        intent.setComponent(componentName);
        startActivity(intent);
    }
}
 
Example #2
Source File: AppInfoEngine.java    From AppPlus with MIT License 6 votes vote down vote up
/**
 * get recent running app list
 * @return recent running app list
 */
@Deprecated
public List<AppEntity> getRecentAppList() {
    List<AppEntity> list = new ArrayList<>();
    ActivityManager mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RecentTaskInfo> recentTasks = mActivityManager.getRecentTasks(10, 0);
    for (ActivityManager.RecentTaskInfo taskInfo : recentTasks) {
        Intent intent = taskInfo.baseIntent;
        ResolveInfo resolveInfo = mPackageManager.resolveActivity(intent, 0);
        if (resolveInfo == null)continue;
        String packageName = resolveInfo.activityInfo.packageName;
        if (isSystemApp(packageName)) continue;
        if (isShowSelf(packageName)) continue;
        AppEntity appEntity = DataHelper.getAppByPackageName(packageName);
        if (appEntity == null)continue;
        list.add (appEntity);
    }
    return list;
}
 
Example #3
Source File: GenerateShortcutHelper.java    From TvAppRepo with Apache License 2.0 6 votes vote down vote up
public static void begin(final Activity activity, final ResolveInfo resolveInfo) {
    new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.dialog_theme))
            .setTitle(activity.getString(R.string.title_shortcut_generator,
                    resolveInfo.activityInfo.applicationInfo.loadLabel(activity.getPackageManager())))
            .setMessage(R.string.shortcut_generator_info)
            .setPositiveButton(R.string.create_shortcut, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    generateShortcut(activity, resolveInfo);
                }
            })
            .setNeutralButton(R.string.advanced, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // Open a new dialog
                    openAdvancedOptions(activity, resolveInfo);
                }
            })
            .setNegativeButton(R.string.cancel, null)
            .show();
}
 
Example #4
Source File: CropImage.java    From Lassi-Android with MIT License 6 votes vote down vote up
/**
 * Get all Camera intents for capturing image using device camera apps.
 */
public static List<Intent> getCameraIntents(
        @NonNull Context context, @NonNull PackageManager packageManager) {

    List<Intent> allIntents = new ArrayList<>();

    // Determine Uri of camera image to  save.
    Uri outputFileUri = getCaptureImageOutputUri(context);

    Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
    for (ResolveInfo res : listCam) {
        Intent intent = new Intent(captureIntent);
        intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
        intent.setPackage(res.activityInfo.packageName);
        if (outputFileUri != null) {
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
        }
        allIntents.add(intent);
    }

    return allIntents;
}
 
Example #5
Source File: AppUtil.java    From SoloPi with Apache License 2.0 6 votes vote down vote up
/**
 * 通过adb启动应用
 * @param appPackage
 * @return
 */
public static boolean startApp(String appPackage) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setPackage(appPackage);
    List<ResolveInfo> resolveInfos = LauncherApplication.getContext().getPackageManager().queryIntentActivities(intent, 0);
    if (resolveInfos == null || resolveInfos.size() == 0) {
        return false;
    }

    // 多Launcher情景
    for (ResolveInfo resolveInfo : resolveInfos) {
        LogUtil.d(TAG, "resolveInfo:" + resolveInfo);
    }
    String targetActivity = resolveInfos.get(0).activityInfo.name;
    CmdTools.execAdbCmd("am start -n '" + appPackage + "/" + targetActivity + "'", 2000);
    return true;
}
 
Example #6
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * @hide
 */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentReceivers(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags,  userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #7
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * @hide
 */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentReceivers(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags,  userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #8
Source File: AppPickerPreference.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
public ShortcutItem(String appName, ResolveInfo ri) {
    mAppName = appName;
    mResolveInfo = ri;
    if (mResolveInfo != null) {
        mCreateShortcutIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
        ComponentName cn = new ComponentName(mResolveInfo.activityInfo.packageName,
                mResolveInfo.activityInfo.name);
        mCreateShortcutIntent.setComponent(cn);
        // mark intent so we can later identify it comes from GB
        mCreateShortcutIntent.putExtra("gravitybox", true);
        if (mAllowUnlockAction) {
            mCreateShortcutIntent.putExtra(ShortcutActivity.EXTRA_ALLOW_UNLOCK_ACTION, true);
        }
        if (mLaunchesFromLockscreen) {
            mCreateShortcutIntent.putExtra(ShortcutActivity.EXTRA_LAUNCHES_FROM_LOCKSCREEN, true);
        }
    }
}
 
Example #9
Source File: DeviceAdmins.java    From island with Apache License 2.0 6 votes vote down vote up
private static ComponentName queryComponentName(final Context context) {
	final List<ComponentName> active_admins = requireNonNull((DevicePolicyManager) context.getSystemService(DEVICE_POLICY_SERVICE)).getActiveAdmins();
	if (active_admins != null && ! active_admins.isEmpty()) for (final ComponentName active_admin : active_admins)
		if (Modules.MODULE_ENGINE.equals(active_admin.getPackageName())) return active_admin;

	final Intent intent = new Intent(DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED).setPackage(Modules.MODULE_ENGINE);
	final List<ResolveInfo> admins = context.getPackageManager().queryBroadcastReceivers(intent, PackageManager.GET_DISABLED_COMPONENTS);
	if (admins.size() == 1) {
		final ResolveInfo admin = admins.get(0);
		sDeviceAdminComponent = new ComponentName(Modules.MODULE_ENGINE, admins.get(0).activityInfo.name);
		if (! admin.activityInfo.enabled) {
			Analytics.$().event("device_admin_component_disabled").with(ITEM_ID, sDeviceAdminComponent.flattenToShortString()).send();
			context.getPackageManager().setComponentEnabledSetting(sDeviceAdminComponent, COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
		}
		return sDeviceAdminComponent;
	}	// No resolve result on some Android 7.x devices, cause unknown.
	if (BuildConfig.DEBUG) throw new IllegalStateException("Engine module is not correctly installed: " + admins);
	return new ComponentName(Modules.MODULE_ENGINE, "com.oasisfeng.island.IslandDeviceAdminReceiver");	// Fallback
}
 
Example #10
Source File: SelectionPopupController.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Intialize the menu items for processing text, if there is any.
 */
private void initializeTextProcessingMenu(Menu menu) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
            || !isSelectActionModeAllowed(MENU_ITEM_PROCESS_TEXT)) {
        return;
    }

    PackageManager packageManager = mContext.getPackageManager();
    List<ResolveInfo> supportedActivities =
            packageManager.queryIntentActivities(createProcessTextIntent(), 0);
    for (int i = 0; i < supportedActivities.size(); i++) {
        ResolveInfo resolveInfo = supportedActivities.get(i);
        CharSequence label = resolveInfo.loadLabel(mContext.getPackageManager());
        menu.add(R.id.select_action_menu_text_processing_menus, Menu.NONE,
                MENU_ITEM_ORDER_TEXT_PROCESS_START + i, label)
                .setIntent(createProcessTextIntentForResolveInfo(resolveInfo))
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
}
 
Example #11
Source File: ShareChooserDialog.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    parentWidth = getArguments().getInt(ARG_WIDTH, 640);
    shareIntent = getArguments().getParcelable(ARG_INTENT);
    showNearby = getArguments().getBoolean(ARG_SHOW_NEARBY, false);
    targets = new ArrayList<>();
    List<ResolveInfo> resInfo = getContext().getPackageManager().queryIntentActivities(shareIntent, 0);
    if (resInfo != null && resInfo.size() > 0) {
        for (ResolveInfo resolveInfo : resInfo) {
            String packageName = resolveInfo.activityInfo.packageName;
            if (!packageName.equals(BuildConfig.APPLICATION_ID)) { // Remove ourselves
                targets.add(resolveInfo);
            }
        }
    }
}
 
Example #12
Source File: AwoPatchReceiver.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void restart() {
    Intent
        intent = RuntimeVariables.androidApplication.getPackageManager().getLaunchIntentForPackage(RuntimeVariables.androidApplication.getPackageName());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
            Intent.FLAG_ACTIVITY_NEW_TASK);
    ResolveInfo info = RuntimeVariables.androidApplication.getPackageManager().resolveActivity(intent, 0);
    if (info != null) {
        Log.d("PatchReceiver", info.activityInfo.name);
    } else {
        Log.d("PatchReceiver", "no activity");

    }
    // RuntimeVariables.androidApplication.startActivity(intent);
    kill();
    android.os.Process.killProcess(android.os.Process.myPid());
    // System.exit(0);
}
 
Example #13
Source File: VAccountManagerService.java    From container with GNU General Public License v3.0 6 votes vote down vote up
private void generateServicesMap(List<ResolveInfo> services, Map<String, AuthenticatorInfo> map,
		IAccountParser accountParser) {
	for (ResolveInfo info : services) {
		XmlResourceParser parser = accountParser.getParser(mContext, info.serviceInfo,
				AccountManager.AUTHENTICATOR_META_DATA_NAME);
		if (parser != null) {
			try {
				AttributeSet attributeSet = Xml.asAttributeSet(parser);
				int type;
				while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
					// Nothing to do
				}
				if (AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME.equals(parser.getName())) {
					AuthenticatorDescription desc = parseAuthenticatorDescription(
							accountParser.getResources(mContext, info.serviceInfo.applicationInfo),
							info.serviceInfo.packageName, attributeSet);
					if (desc != null) {
						map.put(desc.type, new AuthenticatorInfo(desc, info.serviceInfo));
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
 
Example #14
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentServicesAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentServices(intent,
                intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #15
Source File: Reddit.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
public static HashMap<String, String> getInstalledBrowsers() {
    int packageMatcher =
            SDK_INT >= M ? PackageManager.MATCH_ALL : PackageManager.GET_DISABLED_COMPONENTS;

    HashMap<String, String> browserMap = new HashMap<>();

    final List<ResolveInfo> resolveInfoList = getAppContext().getPackageManager()
            .queryIntentActivities(
                    new Intent(Intent.ACTION_VIEW, Uri.parse("http://ccrama.me")),
                    packageMatcher);

    for (ResolveInfo resolveInfo : resolveInfoList) {
        if (resolveInfo.activityInfo.enabled) {
            browserMap.put(resolveInfo.activityInfo.applicationInfo.packageName,
                    Reddit.getAppContext()
                            .getPackageManager()
                            .getApplicationLabel(resolveInfo.activityInfo.applicationInfo)
                            .toString());
        }
    }

    return browserMap;
}
 
Example #16
Source File: NativeProtocol.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 6 votes vote down vote up
static Intent validateKatanaServiceIntent(Context context, Intent intent) {
    if (intent == null) {
        return null;
    }

    ResolveInfo resolveInfo = context.getPackageManager().resolveService(intent, 0);
    if (resolveInfo == null) {
        return null;
    }

    if (!validateSignature(context, resolveInfo.serviceInfo.packageName)) {
        return null;
    }

    return intent;
}
 
Example #17
Source File: ActivityManagerProxy.java    From VirtualAPK with Apache License 2.0 6 votes vote down vote up
protected void getIntentSender(Method method, Object[] args) {
    String hostPackageName = mPluginManager.getHostContext().getPackageName();
    args[1] = hostPackageName;

    Intent target = ((Intent[]) args[5])[0];
    int intentSenderType = (int)args[0];
    if (intentSenderType == INTENT_SENDER_ACTIVITY) {
        mPluginManager.getComponentsHandler().transformIntentToExplicitAsNeeded(target);
        mPluginManager.getComponentsHandler().markIntentIfNeeded(target);
    } else if (intentSenderType == INTENT_SENDER_SERVICE) {
        ResolveInfo resolveInfo = this.mPluginManager.resolveService(target, 0);
        if (resolveInfo != null && resolveInfo.serviceInfo != null) {
            // find plugin service
            Intent wrapperIntent  = wrapperTargetIntent(target, resolveInfo.serviceInfo, null, RemoteService.EXTRA_COMMAND_START_SERVICE);
            ((Intent[]) args[5])[0] = wrapperIntent;
        }
    } else if (intentSenderType == INTENT_SENDER_BROADCAST) {
        // no action
    }
}
 
Example #18
Source File: CorrectionSettingsFragment.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_correction);

    final Context context = getActivity();
    final PackageManager pm = context.getPackageManager();

    final Preference dictionaryLink = findPreference(Settings.PREF_CONFIGURE_DICTIONARIES_KEY);
    final Intent intent = dictionaryLink.getIntent();
    intent.setClassName(context.getPackageName(), DictionarySettingsActivity.class.getName());
    final int number = pm.queryIntentActivities(intent, 0).size();
    if (0 >= number) {
        removePreference(Settings.PREF_CONFIGURE_DICTIONARIES_KEY);
    }

    final Preference editPersonalDictionary =
            findPreference(Settings.PREF_EDIT_PERSONAL_DICTIONARY);
    final Intent editPersonalDictionaryIntent = editPersonalDictionary.getIntent();
    final ResolveInfo ri = USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS ? null
            : pm.resolveActivity(
                    editPersonalDictionaryIntent, PackageManager.MATCH_DEFAULT_ONLY);
    if (ri == null) {
        overwriteUserDictionaryPreference(editPersonalDictionary);
    }

    mUseContactsPreference = (SwitchPreference) findPreference(Settings.PREF_KEY_USE_CONTACTS_DICT);
    turnOffUseContactsIfNoPermission();
}
 
Example #19
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public Intent getLaunchIntentForPackage(String packageName) {
    // First see if the package has an INFO activity; the existence of
    // such an activity is implied to be the desired front-door for the
    // overall package (such as if it has multiple launcher entries).
    Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
    intentToResolve.addCategory(Intent.CATEGORY_INFO);
    intentToResolve.setPackage(packageName);
    List<ResolveInfo> ris = queryIntentActivities(intentToResolve, 0);

    // Otherwise, try to find a main launcher activity.
    if (ris == null || ris.size() <= 0) {
        // reuse the intent instance
        intentToResolve.removeCategory(Intent.CATEGORY_INFO);
        intentToResolve.addCategory(Intent.CATEGORY_LAUNCHER);
        intentToResolve.setPackage(packageName);
        ris = queryIntentActivities(intentToResolve, 0);
    }
    if (ris == null || ris.size() <= 0) {
        return null;
    }
    Intent intent = new Intent(intentToResolve);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClassName(ris.get(0).activityInfo.packageName,
            ris.get(0).activityInfo.name);
    return intent;
}
 
Example #20
Source File: LoadedPlugin.java    From VirtualAPK with Apache License 2.0 5 votes vote down vote up
@Override
public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags) {
    ComponentName component = intent.getComponent();
    if (null == component) {
        if (intent.getSelector() != null) {
            intent = intent.getSelector();
            component = intent.getComponent();
        }
    }

    if (null != component) {
        LoadedPlugin plugin = mPluginManager.getLoadedPlugin(component);
        if (null != plugin) {
            ActivityInfo activityInfo = plugin.getReceiverInfo(component);
            if (activityInfo != null) {
                ResolveInfo resolveInfo = new ResolveInfo();
                resolveInfo.activityInfo = activityInfo;
                return Arrays.asList(resolveInfo);
            }
        }
    }

    List<ResolveInfo> all = new ArrayList<>();

    List<ResolveInfo> pluginResolveInfos = mPluginManager.queryBroadcastReceivers(intent, flags);
    if (null != pluginResolveInfos && pluginResolveInfos.size() > 0) {
        all.addAll(pluginResolveInfos);
    }

    List<ResolveInfo> hostResolveInfos = this.mHostPackageManager.queryBroadcastReceivers(intent, flags);
    if (null != hostResolveInfos && hostResolveInfos.size() > 0) {
        all.addAll(hostResolveInfos);
    }

    return all;
}
 
Example #21
Source File: LoadedPlugin.java    From VirtualAPK with Apache License 2.0 5 votes vote down vote up
public ResolveInfo resolveActivity(Intent intent, int flags) {
    List<ResolveInfo> query = this.queryIntentActivities(intent, flags);
    if (null == query || query.isEmpty()) {
        return null;
    }

    ContentResolver resolver = this.mPluginContext.getContentResolver();
    return chooseBestActivity(intent, intent.resolveTypeIfNeeded(resolver), flags, query);
}
 
Example #22
Source File: PluginHostDelegateActivity.java    From AndroidPlugin with MIT License 5 votes vote down vote up
@Override
public ComponentName startService(Intent service) {
	List<ResolveInfo> resolveInfos = getPackageManager()
			.queryIntentServices(service, PackageManager.MATCH_DEFAULT_ONLY);
	if (resolveInfos == null || resolveInfos.isEmpty()) {
		service.setPackage(mDelegatedActivity.getPackageName());
	} else {
		return super.startService(service);
	}
	return PluginClientManager.sharedInstance(this).startService(this,
			service);
}
 
Example #23
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public Intent getLaunchIntentForPackage(String packageName) {
    // First see if the package has an INFO activity; the existence of
    // such an activity is implied to be the desired front-door for the
    // overall package (such as if it has multiple launcher entries).
    Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
    intentToResolve.addCategory(Intent.CATEGORY_INFO);
    intentToResolve.setPackage(packageName);
    List<ResolveInfo> ris = queryIntentActivities(intentToResolve, 0);

    // Otherwise, try to find a main launcher activity.
    if (ris == null || ris.size() <= 0) {
        // reuse the intent instance
        intentToResolve.removeCategory(Intent.CATEGORY_INFO);
        intentToResolve.addCategory(Intent.CATEGORY_LAUNCHER);
        intentToResolve.setPackage(packageName);
        ris = queryIntentActivities(intentToResolve, 0);
    }
    if (ris == null || ris.size() <= 0) {
        return null;
    }
    Intent intent = new Intent(intentToResolve);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClassName(ris.get(0).activityInfo.packageName,
            ris.get(0).activityInfo.name);
    return intent;
}
 
Example #24
Source File: TtsData.java    From android-app with GNU General Public License v3.0 5 votes vote down vote up
public void init(Context context, ActivityForResultStarter activityForResultStarter) {
    if (engines != null) return;
    Log.d(TAG, "init()");

    PackageManager pm = context.getPackageManager();

    Intent ttsIntent = new Intent();
    ttsIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);

    List<ResolveInfo> resolveInfoList = pm
            .queryIntentActivities(ttsIntent, PackageManager.GET_META_DATA);

    numberOfEngines = resolveInfoList.size();

    engines = new ArrayList<>(numberOfEngines);

    for (ResolveInfo resolveInfo : resolveInfoList) {
        DisplayName engineInfo = new DisplayName(
                resolveInfo.activityInfo.applicationInfo.packageName,
                resolveInfo.loadLabel(pm).toString());

        Log.d(TAG, "init() " + engineInfo.name + ": " + engineInfo.displayName);

        engines.add(engineInfo);

        Intent getVoicesIntent = new Intent();
        getVoicesIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
        getVoicesIntent.setPackage(engineInfo.name);
        getVoicesIntent.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);

        activityForResultStarter.startActivityForResult(
                getVoicesIntent, maskRequestCode(engines.size() - 1));
    }
}
 
Example #25
Source File: MaterialActivityChooserActivity.java    From material-activity-chooser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActivityLongClicked(ResolveInfo activity) {
    String packageName = activity.activityInfo.packageName;

    Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.parse("package:" + packageName));
    startActivity(intent);

    return true;
}
 
Example #26
Source File: ImPluginHelper.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
public List<String> getProviderNames() {
    List<ResolveInfo> plugins = getPlugins();
    List<String> names = new ArrayList<String>();
    for (ResolveInfo plugin : plugins) {
        names.add(plugin.serviceInfo.metaData
                .getString(ImPluginConstants.METADATA_PROVIDER_NAME));
    }
    return names;
}
 
Example #27
Source File: DelegateApplicationPackageManager.java    From BtPlayer with Apache License 2.0 5 votes vote down vote up
@Override public Drawable getActivityIcon(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityIcon(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
            intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadIcon(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example #28
Source File: TwaProviderPickerTest.java    From android-browser-helper with Apache License 2.0 5 votes vote down vote up
private void installCustomTabsProvider(String packageName) {
    installBrowser(packageName);

    Intent intent = new Intent()
            .setAction(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);

    ResolveInfo resolveInfo = new ResolveInfo();
    resolveInfo.serviceInfo = new ServiceInfo();
    resolveInfo.serviceInfo.packageName = packageName;

    mShadowPackageManager.addResolveInfoForIntent(intent, resolveInfo);
}
 
Example #29
Source File: CBrowserWindow.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean checkInstallApp(Context context, Intent target) {
    final PackageManager packageManager = context.getPackageManager();
    List<ResolveInfo> list = packageManager.queryIntentActivities(target,
            PackageManager.MATCH_DEFAULT_ONLY);
    if (null != list && list.size() > 0) {
        return true;
    }
    return false;
}
 
Example #30
Source File: OrbotHelper.java    From bitmask_android with GNU General Public License v3.0 5 votes vote down vote up
public static boolean checkTorReceier(Context c) {
    Intent startOrbot = getOrbotStartIntent(c);
    PackageManager pm = c.getPackageManager();
    Intent result = null;
    List<ResolveInfo> receivers =
            pm.queryBroadcastReceivers(startOrbot, 0);

    return receivers != null && receivers.size() > 0;
}