I'm trying to get a resource id for a mp3 file within a fragment and I can't find out how to do this. The following code returns zero for the resource id. Yes, the file is there in the raw directory. (I'm using ActionBarSherlock, but I'm not sure that matters.)
public class NavigationFragment extends SherlockFragment {
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
View nav =inflater.inflate(R.layout.navigation, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
try {
int resourceID = getResources().getIdentifier("bell01", "raw", "com.webnation.yogatest");
Log.d("We're Here", "resourceID =" + resourceID);
bell = MediaPlayer.create(getActivity(), resourceID);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.d("Exception", e.toString());
}
} //onActivityCreated
}
manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.webnation.yogatest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
<activity
android:name="com.webnation.yogatest.YogaTestActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".EulaActivity"
android:label="@string/title_eula_activity" >
</activity>
</application>
</manifest>