當前位置: 首頁>>代碼示例>>Java>>正文


Java NameNotFoundException.printStackTrace方法代碼示例

本文整理匯總了Java中android.content.pm.PackageManager.NameNotFoundException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java NameNotFoundException.printStackTrace方法的具體用法?Java NameNotFoundException.printStackTrace怎麽用?Java NameNotFoundException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.pm.PackageManager.NameNotFoundException的用法示例。


在下文中一共展示了NameNotFoundException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAppVersionCode

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
public static int getAppVersionCode(Context context) {
    if (context != null) {
        PackageManager pm = context.getPackageManager();
        if (pm != null) {
            PackageInfo pi;
            try {
                pi = pm.getPackageInfo(context.getPackageName(), 0);
                if (pi != null) {
                    return pi.versionCode;
                }
            } catch (NameNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
    return -1;
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:18,代碼來源:PackageUtil.java

示例2: getRegistrationId

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
private String getRegistrationId(Context context) {
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId=="") {
        Log.i(TAG, "GCM Registration not found in prefs.");
        return "";
    }
    // Check if app was updated; if so, it must clear the registration ID
    // since the existing regID is not guaranteed to work with the new
    // app version.
    String registeredVersion = prefs.getString(FlowzrSyncOptions.PROPERTY_APP_VERSION, "");
    String currentVersion;
	try {
		currentVersion = getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName;
	    if (!registeredVersion.equals(currentVersion)) {
	        Log.i(TAG, "App version changed.");
	        return "";
	    }
	} catch (NameNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    return registrationId;
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:25,代碼來源:FlowzrSyncActivity.java

示例3: getMetaData

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
public static String getMetaData(Context context, @NonNull String key) {
    String metaDataValue = "";
    try {
        PackageManager packageManager = context.getPackageManager();
        if (packageManager != null) {
            ApplicationInfo applicationInfo = packageManager.getApplicationInfo(
                    context.getPackageName(), PackageManager.GET_META_DATA);
            if (applicationInfo != null && applicationInfo.metaData != null) {
                metaDataValue = applicationInfo.metaData.getString(key);
            }
        }
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    return metaDataValue;
}
 
開發者ID:jiajieshen,項目名稱:AndroidDevSamples,代碼行數:18,代碼來源:ApplicationUtil.java

示例4: getAppName

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
/**
 * 獲得APP的名稱
 *
 * @param context
 * @return
 */
public static String getAppName(Context context) {
    if (context == null) {
        return null;
    }
    try {
        PackageManager packageManager = context.getPackageManager();
        PackageInfo packageInfo = packageManager.getPackageInfo(
                context.getPackageName(), 0);
        int labelRes = packageInfo.applicationInfo.labelRes;
        String appName = context.getResources().getString(labelRes);
        return appName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:TIIEHenry,項目名稱:TIIEHenry-Android-SDK,代碼行數:23,代碼來源:AppUtils.java

示例5: getPackageInfo

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
/**
 * 獲取指定程序信息
 */
public static android.content.pm.PackageInfo getPackageInfo(Context context, String pkg) {
    try {
        return context.getPackageManager().getPackageInfo(pkg, 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:lanyuanxiaoyao,項目名稱:PicKing,代碼行數:12,代碼來源:PackageUtil.java

示例6: getPackageInfo

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
/**
 * 獲取指定程序信息
 */
public static PackageInfo getPackageInfo(Context context, String pkg) {
    try {
        return context.getPackageManager().getPackageInfo(pkg, 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:12,代碼來源:PackageUtil.java

示例7: getChannel

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
public static String getChannel(Context context , String channelKey) {
	String msg = null;
	try {
		ApplicationInfo appInfo = context.getPackageManager() .getApplicationInfo(context.getPackageName(),
				PackageManager.GET_META_DATA);
		msg=appInfo.metaData.getString(channelKey);
	} catch (NameNotFoundException e) {
		e.printStackTrace();
	}
	return msg;
}
 
開發者ID:ebridfighter,項目名稱:GongXianSheng,代碼行數:12,代碼來源:CommonUtils.java

示例8: onCreate

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    try {
        mPackageInfo = getPackageManager().getPackageInfo(
                getPackageName(), 0);
        ApplicationInfo ai = getApplicationInfo();
        CharSequence applicationLabel = getPackageManager().getApplicationLabel(ai);
        mNotification = new DownloadNotification(this, applicationLabel);

    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
}
 
開發者ID:snoozinsquatch,項目名稱:unity-obb-downloader,代碼行數:15,代碼來源:DownloaderService.java

示例9: initWithApiKey

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
private void initWithApiKey(Context context) {
    try {
        ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(context
                .getPackageName(), 128);
        Object leyu_app_id = appInfo.metaData.get("leyu_app_id");
        Object leyu_app_key = appInfo.metaData.get("leyu_app_key");
        _app_id = String.valueOf(leyu_app_id);
        _app_key = String.valueOf(leyu_app_key);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        this._callback.onFailed(e.getMessage());
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:14,代碼來源:LEYUApplication.java

示例10: getAppVersionName

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
public static String getAppVersionName(Context context) {
    String version = "0";
    try {
        version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return version;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:10,代碼來源:SystemUtils.java

示例11: getText

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
@Override
public String getText() {
    if (mName == null) {
        try {
            PackageManager pm = mContext.getPackageManager();
            PackageInfo pi = pm.getPackageInfo(mPackage, 0);
            mName = (String) pi.applicationInfo.loadLabel(pm);
        } catch (NameNotFoundException e) {
            e.printStackTrace();
            mName = mPackage;
        }
    }
    return mName; 
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:15,代碼來源:OngoingNotifPreference.java

示例12: getVersionCode

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
/**
 * 獲取APP版本號
 *
 * @param context
 * @return
 */
public static int getVersionCode(Context context) {
    int verCode = -1;
    try {
        verCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return verCode;
}
 
開發者ID:xiarunhao123,項目名稱:Ency,代碼行數:16,代碼來源:AppApplicationUtil.java

示例13: loadVersionInfo

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
private static final void loadVersionInfo(Context context) {
	try {
		PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
		if (pi != null) {
			versionCode = pi.versionCode;
			versionName = pi.versionName;
		}
	} catch (NameNotFoundException e) {
		e.printStackTrace();
	}
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:12,代碼來源:InstallUtil.java

示例14: isSystemApplication

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
/**
 * whether packageName is system application
 *
 * @param packageManager
 * @param packageName
 * @return <ul>
 * <li>if packageManager is null, return false</li>
 * <li>if package name is null or is empty, return false</li>
 * <li>if package name not exit, return false</li>
 * <li>if package name exit, but not system app, return false</li>
 * <li>else return true</li>
 * </ul>
 */
public static boolean isSystemApplication(PackageManager packageManager, String packageName) {
    if (packageManager == null || packageName == null || packageName.length() == 0) {
        return false;
    }

    try {
        ApplicationInfo app = packageManager.getApplicationInfo(packageName, 0);
        return (app != null && (app.flags & ApplicationInfo.FLAG_SYSTEM) > 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return false;
}
 
開發者ID:lizhangqu,項目名稱:CorePatch,代碼行數:27,代碼來源:PackageUtils.java

示例15: getClientVersionName

import android.content.pm.PackageManager.NameNotFoundException; //導入方法依賴的package包/類
public static String getClientVersionName(Context context) {
    if (context == null) {
        return "";
    }
    try {
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        return "";
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:12,代碼來源:DataUtils.java


注:本文中的android.content.pm.PackageManager.NameNotFoundException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。