Actually i'm trying to implement zebra EMDK library to my yet existing project. I've followed step by step the following guide and in a new project all worked perfectly but when i've tryed to use the library in my project i've got the following error:
2019-03-13 15:24:55.720 4671-4678/it.gabtamagnini.realco E/art: Failed sending reply to debugger: Broken pipe
2019-03-13 15:25:01.239 4671-4671/it.gabtamagnini.realco E/AndroidRuntime: FATAL EXCEPTION: main
Process: it.gabtamagnini.realco, PID: 4671
java.lang.RuntimeException: Unable to start activity ComponentInfo{it.gabtamagnini.realco/it.gabtamagnini.realco.InventarioActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contentEquals(java.lang.CharSequence)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contentEquals(java.lang.CharSequence)' on a null object reference
at it.gabtamagnini.realco.InventarioActivity.handleDecodeData(InventarioActivity.java:1160)
at it.gabtamagnini.realco.InventarioActivity.onCreate(InventarioActivity.java:129)
at android.app.Activity.performCreate(Activity.java:6723)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Code where i get the null pointer:
private void handleDecodeData(Intent i) {
//Check the intent action is for us
if (i.getAction().contentEquals("com.symbol.emdksample.RECVR")) {
//Get the source of the data
String source = i.getStringExtra("com.motorolasolutions.emdk.datawedge.source");
//Check if the data has come from the Barcode scanner
if (source.equalsIgnoreCase("scanner")) {
//Get the data from the intent
String data = i.getStringExtra("com.motorolasolutions.emdk.datawedge.data_string");
//Check that we have received data
if(data != null && data.length() > 0)
{
Toast.makeText(InventarioActivity.this,data,Toast.LENGTH_LONG).show();
}
}
}
}
that tutorial is quite old - Data Capture Profiles were recently deprecated. If you are trying this on a newer device then I suspect the com.motorolasolutions... Intents have been removed as the string extra has been 'com.symbol.datawedge.data_string for quite some time. I suggest reading https://developer.zebra.com/community/home/blog/2018/06/03/moving-from-the-emdk-data-capture-profile-to-datawedge which explains what has happened to the Data Capture profile but if you are looking for a known working sample then http://www.darryncampbell.co.uk/2017/12/13/tutorial-scan-with-datawedge-intent-output-on-zebra-devices/ should be a good starting point.
For clarity, I work for Zebra