Search in sources :

Example 16 with PackageManager

use of android.content.pm.PackageManager 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)

Example 17 with PackageManager

use of android.content.pm.PackageManager in project UltimateAndroid by cymcsg.

the class BasicUtils method getVersionName.

/**
     * get the version name which defines in AndroidManifest.xml
     *
     * @param context
     * @return
     */
public static String getVersionName(Context context) {
    String version = "";
    try {
        // get packagemanager
        PackageManager packageManager = context.getPackageManager();
        // getPackageName()--your current package name,0 means get package info
        PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
        version = packInfo.versionName;
    } catch (Exception e) {
        e.printStackTrace();
        Logs.e(e.getMessage());
    } finally {
        return version;
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo)

Example 18 with PackageManager

use of android.content.pm.PackageManager in project UltimateAndroid by cymcsg.

the class BasicUtils method getVersionCode.

/**
     * get the version code which defines in AndroidManifest.xml
     *
     * @param context
     * @return
     */
public static int getVersionCode(Context context) {
    int version = 0;
    try {
        // get packagemanager
        PackageManager packageManager = context.getPackageManager();
        // getPackageName()--your current package name,0 means get package info
        PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
        version = packInfo.versionCode;
    } catch (Exception e) {
        e.printStackTrace();
        Logs.e(e.getMessage());
    } finally {
        return version;
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo)

Example 19 with PackageManager

use of android.content.pm.PackageManager in project UltimateAndroid by cymcsg.

the class LandingFragment method getData.

protected List<Map<String, ?>> getData(String prefix) {
    List<Map<String, ?>> myData = new ArrayList<Map<String, ?>>();
    Intent intent = new Intent("com.marshalchen.common.demoofui", null);
    PackageManager pm = getActivity().getPackageManager();
    List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
    if (null == list)
        return myData;
    int len = list.size();
    for (int i = 0; i < len; i++) {
        ResolveInfo info = list.get(i);
        String activityName = info.activityInfo.name;
        String[] labelPath = activityName.split("\\.");
        String nextLabel = labelPath[labelPath.length - 1];
        addItem(myData, nextLabel, activityIntent(info.activityInfo.applicationInfo.packageName, info.activityInfo.name));
    }
    Collections.sort(myData, sDisplayNameComparator);
    addItemToTop(myData, "SignaturePadActivity", new Intent(getActivity(), SignaturePadActivity.class));
    addItemToTop(myData, "SmoothProgressBarActivity", new Intent(getActivity(), SmoothProgressBarActivity.class));
    addItemToTop(myData, "RippleEffectActivity", new Intent(getActivity(), RippleEffectActivity.class));
    addItemToTop(myData, "NumberProgressBarActivity", new Intent(getActivity(), NumberProgressBarActivity.class));
    addItemToTop(myData, "MotionSampleActivity", new Intent(getActivity(), MotionSampleActivity.class));
    addItemToTop(myData, "MaterialMenuToolbarActivity", new Intent(getActivity(), MaterialMenuToolbarActivity.class));
    //        addItemToTop(myData,
    //                "MaterialListViewActivity",
    //                new Intent(getActivity(), MaterialListViewActivity.class));
    addItemToTop(myData, "KenBurnsViewActivity", new Intent(getActivity(), KenBurnsViewActivity.class));
    addItemToTop(myData, "GestureTouchActivity", new Intent(getActivity(), GestureTouchActivity.class));
    addItemToTop(myData, "FloatingActionButtonDemo", new Intent(getActivity(), FloatingActionButtonDemo.class));
    addItemToTop(myData, "CoolDragAndDropActivity", new Intent(getActivity(), CoolDragAndDropActivity.class));
    addItemToTop(myData, "MaterialDesignActivity", new Intent(getActivity(), MaterialDesignActivity.class));
    addItemToTop(myData, "MaterialAnimationActivity", new Intent(getActivity(), MaterialAnimationActivity.class));
    addItemToTop(myData, "SearchDrawableActivity", new Intent(getActivity(), SearchDrawableActivity.class));
    addItemToTop(myData, "UltimateRecyclerViewActivity", new Intent(getActivity(), UltimateRecyclerViewActivity.class));
    return myData;
}
Also used : MaterialMenuToolbarActivity(com.marshalchen.common.demoofui.materialmenu.MaterialMenuToolbarActivity) SearchDrawableActivity(com.marshalchen.common.demoofui.sampleModules.SearchDrawableActivity) GestureTouchActivity(com.marshalchen.common.demoofui.sampleModules.GestureTouchActivity) CoolDragAndDropActivity(com.marshalchen.common.demoofui.cooldraganddrop.CoolDragAndDropActivity) ArrayList(java.util.ArrayList) Intent(android.content.Intent) MaterialAnimationActivity(com.marshalchen.common.demoofui.materialAnimations.MaterialAnimationActivity) KenBurnsViewActivity(com.marshalchen.common.demoofui.sampleModules.KenBurnsViewActivity) FloatingActionButtonDemo(com.marshalchen.common.demoofui.sampleModules.FloatingActionButtonDemo) UltimateRecyclerViewActivity(com.marshalchen.common.demoofui.ultimaterecyclerview.UltimateRecyclerViewActivity) ResolveInfo(android.content.pm.ResolveInfo) MaterialDesignActivity(com.marshalchen.common.demoofui.materialdesigndemo.MaterialDesignActivity) NumberProgressBarActivity(com.marshalchen.common.demoofui.sampleModules.NumberProgressBarActivity) MotionSampleActivity(com.marshalchen.common.demoofui.sampleModules.MotionSampleActivity) PackageManager(android.content.pm.PackageManager) RippleEffectActivity(com.marshalchen.common.demoofui.sampleModules.RippleEffectActivity) HashMap(java.util.HashMap) Map(java.util.Map) SignaturePadActivity(com.marshalchen.common.demoofui.sampleModules.SignaturePadActivity)

Example 20 with PackageManager

use of android.content.pm.PackageManager in project SimplifyReader by chentao0707.

the class YoukuPlayerView method initialize.

public void initialize(YoukuBasePlayerActivity mYoukuBaseActivity, String pid) {
    PackageManager pm = mYoukuBaseActivity.getPackageManager();
    String ver = "4.1";
    try {
        ver = pm.getPackageInfo(mYoukuBaseActivity.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    boolean isTablet = (this.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
    String ua = (isTablet ? "Youku HD;" : "Youku;") + ver + ";Android;" + android.os.Build.VERSION.RELEASE + ";" + android.os.Build.MODEL;
    Logger.d(TAG, "initialize(): ua = " + ua);
    initialize(mYoukuBaseActivity, 10001, pid, ver, ua, false, -7L, "631l1i1x3fv5vs2dxlj5v8x81jqfs2om");
}
Also used : PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Aggregations

PackageManager (android.content.pm.PackageManager)1429 Intent (android.content.Intent)483 ResolveInfo (android.content.pm.ResolveInfo)449 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)345 ApplicationInfo (android.content.pm.ApplicationInfo)249 PackageInfo (android.content.pm.PackageInfo)248 ComponentName (android.content.ComponentName)239 ArrayList (java.util.ArrayList)156 ActivityInfo (android.content.pm.ActivityInfo)135 IOException (java.io.IOException)126 RemoteException (android.os.RemoteException)105 IPackageManager (android.content.pm.IPackageManager)93 Drawable (android.graphics.drawable.Drawable)93 Resources (android.content.res.Resources)90 PendingIntent (android.app.PendingIntent)71 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Context (android.content.Context)63 Bundle (android.os.Bundle)60 HashMap (java.util.HashMap)53 ServiceInfo (android.content.pm.ServiceInfo)46