PackageManager's applicationInfo.name is always null

前端 未结 3 1149
萌比男神i
萌比男神i 2020-12-14 18:54
PackageManager pm = this.getPackageManager();
ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);

List

        
相关标签:
3条回答
  • 2020-12-14 19:35

    Used applicationInfo.loadLabel(packageManagerInstance) to find the Application name, but there should be a reason why applicationInfo.name didn't work.

    Edit

    applicationInfo.name is the name of a Application subclass if you have any.

    0 讨论(0)
  • 2020-12-14 19:40

    The reason name is null is that it really is... null.

    Please refer to the Android manifest documentation:

    android:name The fully qualified name of an Application subclass implemented for the application. When the application process is started, this class is instantiated before any of the application's components.

    The subclass is optional; most applications won't need one. In the absence of a subclass, Android uses an instance of the base Application class.

    What you want is the name of the application, which is set in the label attribute of the application tag, and which Ragunath explained how to get.

    0 讨论(0)
  • 2020-12-14 19:45

    Try this

    Log.d(TAG, ai.processName + "");
    

    or this

    Log.d(TAG, ai.packageName + "");
    
    0 讨论(0)
提交回复
热议问题