Before you begin

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:

  1. From the NDK-Samples repository in GitHub, download the .zip file of the sample apps.
  2. Launch the Native SDK.
  3. On the File menu, click Import.
  4. Expand General, then select Existing Projects into Workspace. Click Next.
  5. Browse to the location where you extracted the sample app and click OK.
  6. 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:
  1. In the Project Explorer view, right-click your project. Click Properties.
  2. In the navigation pane, click C/C++ Build > Settings.
  3. On the Tool Settings tab, click QCC Linker > Libraries.
  4. In the Libraries section, verify that the following entries exist and add any that are missing:
    • bps
    • screen
    • asound

If you want to add any additional libraries, you can do so using the Add Library Wizard.

For a makefile build:
  1. In the Project Explorer, double-click the common.mk file.
  2. Add the following beside LIBS+=
    • bps
    • screen
    • asound
    For example: LIBS+=bps screen asound
  3. On the File menu, click Save.

Allow audio in your application

To allow audio capabilities in your application, you must set application permissions.
  1. In the Project Explorer view, double-click your project's bar-descriptor.xml file.
  2. 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.

  1. In the Project Explorer view, double-click your project's bar-descriptor.xml file.
  2. On the Assets tab, click Add Files.
  3. Locate a .wav file using either File System or Workspace.
  4. 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.

Last modified: 2014-05-14



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus