2016-12-19 44 views
2

我正在开发一个允许用作启动程序的应用程序。我们主要使用最近接受Android 5.1.1升级的三星平板电脑,这似乎改变了我们的应用程序在用作启动器时的行为方式。当应用程序作为启动程序启动时,Android NFC意图不工作

问题是,Android似乎使用默认的com.android.nfc/.NfcRootActivity系统默认活动,而不是我们的应用程序。当应用程序正常启动时,它工作正常。在三星部署更新之前,这被用于工作。

这里是日志剪切。

当作为启动器启动的(NFC不工作)

Line 474: E/NxpNfcJni(1457): setReconnectState = 0x0 
Line 476: D/NativeNfcTag(1457): Starting background presence check 
Line 478: D/NfcDispatcher(1457): tryStartActivity. Send intent. 
Line 480: D/PackageManager(1014): Resolving for NFC Intent { flg=0x10008000 cmp=com.android.nfc/.NfcRootActivity (has extras) } flag 66688 user 0 
Line 480: D/PackageManager(1014): Resolving for NFC Intent { flg=0x10008000 cmp=com.android.nfc/.NfcRootActivity (has extras) } flag 66688 user 0 
Line 480: D/PackageManager(1014): Resolving for NFC Intent { flg=0x10008000 cmp=com.android.nfc/.NfcRootActivity (has extras) } flag 66688 user 0 
Line 482: W/ResourcesManager(1014): Asset path '/system/framework/com.broadcom.nfc.jar' does not exist or contains no resources. 
Line 492: V/WindowManager(1014): addAppToken: AppWindowToken{11f6a866 token=Token{513b8c1 ActivityRecord{951b5a8 u0 com.android.nfc/.NfcRootActivity t24}}} to stack=1 task=24 at 0 
Line 492: V/WindowManager(1014): addAppToken: AppWindowToken{11f6a866 token=Token{513b8c1 ActivityRecord{951b5a8 u0 com.android.nfc/.NfcRootActivity t24}}} to stack=1 task=24 at 0 
Line 498: D/NfcPlugin(1494): onPause Intent { } 
Line 502: D/NfcPlugin(1494): stopNfc 

当开始定期(工作)

Line 261: E/NxpNfcJni(1457): setReconnectState = 0x0 
Line 263: D/PersonaManager(1457): isNFCAllowed 
Line 269: D/NativeNfcTag(1457): Starting background presence check 
Line 273: W/ActivityManager(1014): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=com.bstmedia.xxx/yyy.KioskActivity (has extras) } 
Line 277: D/NfcPlugin(1494): onPause Intent { } 
Line 279: D/NfcPlugin(1494): stopNfc 

以下是我们在清单文件。

<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|uiMode" 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" /> 
      <data android:mimeType="text/xxx" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter>    
    </activity> 

    <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|uiMode" android:keepScreenOn="true" android:label="My App Name" android:launchMode="singleInstance" android:name="yyy.KioskActivity" android:windowSoftInputMode="adjustResize"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.HOME" /> 
     </intent-filter> 
    </activity> 

回答

0

当设备重新启动并且应用程序作为启动程序打开时,似乎没有触发前台调度模式。我们没有找到改变这种行为的方法。

然而,一个快速解决方案是按下“最近的应用程序”按钮,该应用程序一旦应用程序回到前台就激活NFC的forground调度模式。

我们添加https://stackoverflow.com/a/32453115/2616377中的代码,以便在每次重新启动时自动发生这种情况。

我知道这不适用于每个设备或Android版本。但是我们很高兴能够朝这个方向发展,因为这个问题无论如何都是特定于三星的更新。

相关问题