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;
}
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;
}
}
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;
}
}
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;
}
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");
}
Aggregations