2
votes

Can someone help me....

I cant recive intent from Symbol TC75 scanner. I have setup profile that sends intent to my app my app recive null intent.

I have put this code in mainfest file....

    <uses-permission android:name="com.symbol.emdk.permission.EMDK" />
        <uses-library android:name="com.symbol.emdk"/>

<activity
        android:name=".aufladen"
        android:screenOrientation="portrait"
        android:launchMode="singleTask">
        <intent-filter>
            <action android:name="com.draganm.mpreiscontainertracking.BARCODE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

in onCreate i put this

EMDKResults results = EMDKManager.getEMDKManager(this.getApplicationContext(), this);


    if(results.statusCode == STATUS_CODE.FAILURE)
    {
        //Failed to create EMDKManager object
    }
    Intent i = getIntent();
    handleDecodeData(i);


@Override
public void onNewIntent(Intent i) {
    handleDecodeData(i);
}

private void handleDecodeData(Intent i) {
    if (i.getAction().contentEquals("com.draganm.mpreiscontainertracking.BARCODE")) {
        String data = i.getStringExtra("com.motorolasolutions.emdk.datawedge.data_string");

        if (data != null && data.length() > 0) {
        }
        Toast.makeText(this, data, Toast.LENGTH_LONG).show();
    }
}

After i play this app on real device i get this error in log

FATAL EXCEPTION: main Process: com.draganm.mpreiscontainertracking, PID: 5163 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.draganm.mpreiscontainertracking/com.draganm.mpreiscontainertracking.aufladen}: 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:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contentEquals(java.lang.CharSequence)' on a null object reference at com.draganm.mpreiscontainertracking.aufladen.handleDecodeData(aufladen.java:610) at com.draganm.mpreiscontainertracking.aufladen.onCreate(aufladen.java:101) at android.app.Activity.performCreate(Activity.java:6012) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5254)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)

 

1
i.getAction() is nullOneCricketeer

1 Answers

2
votes

I think you are confusing the different ways to retrieve scanned data. Intents are only sent from the DataWedge service (http://techdocs.zebra.com/datawedge/6-0/guide/about/) but you are also initialising the EMDK library (http://techdocs.zebra.com/emdk-for-android/6-0/guide/gettingstarted/). EMDK returns its data via callback.

If you choose the DataWedge route, I have an application which listens for DataWedge intents that might help: https://github.com/darryncampbell/DataWedge-API-Exerciser

If you choose the EMDK route, there are samples on Zebra's own site: http://techdocs.zebra.com/emdk-for-android/6-0/samples/barcode/