chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 557 forks source link

Problem with mimeTypeListener (can't receive mimeType "application/apppackage" info from intent) #230

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi,

I need to lauch app from NFC tag and also pass one more value from tag to app, but I can't work it out how to get them both working together.

I am using NFC phonegap plugin https://github.com/chariotsolutions/phonegap-nfc

I have two tags where I have described information:

1) mimeType: application/customappname, mimeType: text/plain "hi" 2) mimeType: text/customappname, mimeType: text/plain "hi"

Inside the AndroidManifest.xml I have described intent

<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
    <intent-filter android:label="@string/launcher_name">
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.nfc.action.NDEF_DISCOVERED" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="application/customappname" />
        <data android:mimeType="text/customappname" />
    </intent-filter>
</activity>

And in deviceready I have mimeType listeners:

nfc.addMimeTypeListener("application/customappname", onNfc, success, failure);
nfc.addMimeTypeListener("text/customappname", onNfc, success, failure);

Workflows

1) scan tag that has mimeType: application/customappname, mimeType: text/plain "hi" result: application runs, application gets into recent apps history, BUT onNfc from mimeTypeListener is not called and can't get tag info from launch

2) scan tag that has mimeType: text/customappname, mimeType: text/plain "hi" result: application runs, I can also receive world "Hi", but app DOES NOT get into recent apps and minifying application losts needed data and app has to be re-launched.

DOES anyone have some idea why first 1) mimeTypeListener is not triggered when I am using mimeType application/* or why with 2) mimeTypelistener my application doesn't get to recent apps list?

Thank you for your help.

ghost commented 8 years ago

Can be closed, issue happens only with 5.1.1 Android on Sony, but not on other devices.