You should have the following things ready:
- The
BlackBerry 10 Native SDK
- Your BlackBerry 10 device or BlackBerry 10 Device Simulator
- A basic understanding of the C language and some experience
running applications with the Native SDK
Configure your project
To import the complete project:
- From the NDK-Samples repository in GitHub, download the .zip file of the sample apps.
- Launch the Native SDK.
- On the File menu, click
Import.
- Expand General, then
select Existing Projects into Workspace.
Click Next.
- Browse to the location where you extracted the sample app and
click OK.
- Click Finish to import
the project into your workspace
The project appears in the Project Explorer window in the IDE. To
see the source files in the project, you can expand the project folder and then
expand the src folder.
Include libraries for the PlayWav sample app
In your application, you will need to include the following header
files:
#include <errno.h>
#include <fcntl.h>
#include <gulliver.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/slogcodes.h>
#include <ctype.h>
#include <limits.h>
#include <screen/screen.h>
#include <sys/asoundlib.h>
#include <bps/bps.h>
#include <bps/audiomixer.h>
#include <bps/audiodevice.h>
#include <bps/dialog.h>
#include <bps/navigator.h>
#include "dialogutil.h"
Configure your linker settings for the libraries
You must configure the linker to include the non-standard libraries
that your project requires.
For a managed build:
- In the Project
Explorer view, right-click your project. Click Properties.
- In the navigation pane, click C/C++ Build > Settings.
- On the Tool Settings
tab, click QCC Linker >
Libraries.
- In the Libraries
section, verify that the following entries exist and add any that are
missing:
If you want to add any additional libraries, you can do so using the Add Library
Wizard.
For a makefile build:
- In the Project
Explorer, double-click the common.mk file.
- Add the following beside LIBS+=
For example: LIBS+=bps screen
asound
- On the File menu,
click Save.
Allow audio in your application
To allow audio capabilities in your application, you must set
application permissions.
- In the Project
Explorer view, double-click your project's bar-descriptor.xml file.
- On the Application
tab, select the Play Sounds check
box.
Specify a .wav file as an asset
You must add the .wav file to the project assets using the
bar-descriptor.xml file.
- In the Project Explorer
view, double-click your project's bar-descriptor.xml file.
- On the Assets tab,
click Add Files.
- Locate a .wav file using either File System or Workspace.
- Click OK, and then
click Save.
Location of the audio file
The audio file is saved in the /app/native folder relative to where you installed the application.
In this sample application, the name of the audio file is sample.wav.