I am trying to organize my application into packages because it will have several comprehensive list menus. The way I am trying to populate the menus is by finding the activities in each package.
The problem may be with the manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="machinists.toolkit"
android:versionCode="1"
android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:debuggable="true">
<activity
android:label="@string/app_name"
android:name=".MTEActivity"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ExceptionActivity"></activity>
<activity android:name=".activities.ReferenceActivity"></activity>
<activity android:name=".activities.CalculatorActivity"></activity>
<activity android:name=".activities.reference.FormulasActivity"></activity>
<activity android:name=".activities.reference.MaterialsActivity"></activity>
</application>
and the snippet in question is:
try {
this.activities = this.packageManager.getPackageInfo(this.packageName, PackageManager.GET_ACTIVITIES).activities;
} catch (NameNotFoundException e) {...
In this instance this.packageName solves to machinist.toolkit.activities.reference
The getPackageInfo method calls for the full name of the package and that should be correct if I am understanding.
Any idea what is wrong?
Thanks.
No. You are confusing the package of a class and the package of the application. The value supplied to
getPackageInfo()is the package of the application (i.e., the value of yourpackageattribute in the<manifest>element).