how to use queryIntentActivityOptions() method

前端 未结 3 1250
灰色年华
灰色年华 2021-01-29 06:16

Am trying to create a dialog that shows all applications in a user phone that can be used to select a picture from the storage or take one using the camera. below are my two int

3条回答
  •  再見小時候
    2021-01-29 07:05

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView arg0, View arg1, int position,
                                    long arg3) {
                // TODO Auto-generated method stub
                ResolveInfo launchable=appAdapter.getItem(position);
                       String packageName = launchable.activityInfo.packageName;
            String className = launchable.activityInfo.name;
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            ComponentName cn = new ComponentName(packageName, className);
            intent.setComponent(cn);
            startActivity(intent);
            }
        });
    
    
    
     /**
         * Retrieve a set of activities that should be presented to the user as
         * similar options.  This is like {@link #queryIntentActivities}, except it
         * also allows you to supply a list of more explicit Intents that you would
         * like to resolve to particular options, and takes care of returning the
         * final ResolveInfo list in a reasonable order, with no duplicates, based
         * on those inputs.
         *
         * @param caller The class name of the activity that is making the
         *               request.  This activity will never appear in the output
         *               list.  Can be null.
         * @param specifics An array of Intents that should be resolved to the
         *                  first specific results.  Can be null.
         * @param intent The desired intent as per resolveActivity().
         * @param flags Additional option flags.  The most important is
         * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
         * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
         *
         * @return A List<ResolveInfo> containing one entry for each matching
         *         Activity. These are ordered first by all of the intents resolved
         *         in specifics and then any additional activities that
         *         can handle intent but did not get included by one of
         *         the specifics intents.  If there are no matching
         *         activities, an empty list is returned.
         *
         * @see #MATCH_DEFAULT_ONLY
         * @see #GET_INTENT_FILTERS
         * @see #GET_RESOLVED_FILTER
         */
        public abstract List queryIntentActivityOptions(
                ComponentName caller, Intent[] specifics, Intent intent, int flags);
    

提交回复
热议问题