На самом деле я пытаюсь внедрить библиотеку Zebra EMDK в мой еще существующий проект.Я шаг за шагом следовал следующему руководству , и в новом проекте все работало отлично, но когда я попытался использовать библиотеку в своем проекте, я получил следующую ошибку:
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)
Код, где я получаю нулевой указатель:
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();
}
}
}
}