Step by step instruction to build "Hello world" type of Android studio project with libraries needed.
- NurApi.jar Java library for RFID and transport operations.
- NurApiAndroid.aar for Android and device specific operations like Barcode reading, BLE connectivity, battery status, I/O events etc.
- NurApiSmartPair.aar (optional) for easy connection into nearest reader.
- TDTLib.jar (optional) library for dealing with GS1 coded tags
-
Open Android Studio and create a new project with "Empty activity". SDK version must be 21 or higher.
-
Copy NurApi.jar and TDTLib.jar in to
app/libsfolder)
Alternatively, copy NurApi and TDTLib folders from this sample into your project root and set following rows in to the dependecies ofapp/build.gradlefileimplementation files('../NurApi/NurApi.jar')
implementation files('../TDTLib/TDTLib.jar') -
Add NurApiAndroid.aar and other *aar files in to your project as module. (New.. Module --> Import .JAR/.AAR Package --> Browse to location of *.aar file
-
Select the project view
-
Right-click the project and select "Open Module Settings"
-
From left pane, select your app from "Modules"
-
Select "Dependencies" tab
-
Add dependencies by clicking + from the left side of pane.
-
Choose "3. Module dependency" and select *.aar file from list. -->OK to close project window
- Open text view of activity_main.xml
- Add row: "android:id="@+id/id_hello_nur" after <TextView row
- Modify MainActivity.java as below and RUN
- Build and run project. You should see NurApi version number middle of the screen.
import android.widget.TextView;
import com.nordicid.nurapi.*;
public class MainActivity extends AppCompatActivity {
private TextView helloNurText;
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
NurApi mApi = new NurApi();
helloNurText = (TextView)findViewById(R.id.id\_hello\_nur);
helloNurText.setText("Hello NurApi\\nVersion:" \+ mApi.getFileVersion());
} } ````
# Using the API in your application
The API has actually two parts - The NurApi that is same for all Java applications and on top of that is the NurApiAndroid that has some extensions such as battery information and barcode scanning.
In your app declare the API instance and the accessory extension. The latter takes the API as its parameter:
private NurApi mApi = new NurApi();
private NurAccessoryExtension mExtension = new NurAccessoryExtension(mApi);
Next: [Event listener](2_EventListener.md) Add event listener for receiving events from NurApi.