Code example for PackageManager

Methods: getPackageInfo

0
 
	public static int getAmazonVersion(Context ctx) {
		PackageManager pm = ctx.getPackageManager();
		int result = -1;
		try { 
			PackageInfo pi = pm.getPackageInfo("com.amazon.mp3", PackageManager.GET_ACTIVITIES);
			result = pi.versionCode;
		} catch (Exception e) {
			result = -1;
		} 
		return result;
	} 
 
	public static void searchForTrack(Context ctx, String artist, String track) {
		String query = artist + " " + track;
		int searchType = 0;
		Intent intent;
		try { 
			if (getAmazonVersion(ctx) > 60000) {
				intent = new Intent(ACTION_EXTERNAL_EVENT);
				intent.putExtra(EXTRA_EXTERNAL_EVENT_TYPE, TYPE_SEARCH);