0
我正在使用BroadcastReceiver
來註冊包添加事件,只要我得到該事件,我使用getApplicationInfo調用包管理器以獲取有關已安裝包的更多信息。在這個時候我收到了namenoutfoundexception,我相信這是因爲packagemanager沒有更新數據,並且我收到了它之前的事件。我該如何解決這個問題?有任何想法嗎?Android PackageManger - NameNotFound異常
我的代碼:
public void onReceive(Context context, Intent intent) {
// Launch the activity for showing reputation of application
Intent intent1 = new Intent(ApplicationListViewActivity.this,AppViewActivity.class);
//Next create the bundle and initialize it
Bundle bundle = new Bundle();
String pkgName = intent.getData().toString();
//Add the parameters to bundle as
bundle.putString("pkgName",pkgName);
//Add this bundle to the intent
intent1.putExtras(bundle);
startActivity(intent1);
}
try {
ApplicationInfo ai = pm.getApplicationInfo(pkgName, PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
{//end up here}