English 中文(简体)
NFC服务何时终止?
原标题:When exactly is the NFC Service deactivated?

I am wondering when exactly the NFC Service is started and stopped. The source code for android 4.0.3 seems to state that the polling is dependent on a single constant (located in NfcService.java)

/** minimum screen state that enables NFC polling (discovery) */
static final int POLLING_MODE = SCREEN_STATE_ON_UNLOCKED;

I would interpret this as "the screen light is on, therefore the nfc service is active". BUT when the screen is locked, a NFC Tag wont be recognized, altough the screen is lit.

所以,我很好奇:当锁定屏出现时,NFC服务是否已经停止使用,或者它仍在运行,但没有处理标记?

最佳回答

实际上,我不认为NFC Service已被禁用。 当屏幕的值较低时, SCREEN_STATE_ON_UNLOCKED 设备会停止询问 NFC 标签。 您可以从此代码中看到 :

    // configure NFC-C polling
    if (mScreenState >= POLLING_MODE) {
        if (force || !mNfcPollingEnabled) {
            Log.d(TAG, "NFC-C ON");
            mNfcPollingEnabled = true;
            mDeviceHost.enableDiscovery();
        }
    } else {
        if (force || mNfcPollingEnabled) {
            Log.d(TAG, "NFC-C OFF");
            mNfcPollingEnabled = false;
            mDeviceHost.disableDiscovery();
        }
    }

NFC-EE路由被启用的电磁屏状态高于 SCREEN_STATE_ON_Locked :

    // configure NFC-EE routing
    if (mScreenState >= SCREEN_STATE_ON_LOCKED &&
            mEeRoutingState == ROUTE_ON_WHEN_SCREEN_ON) {
        if (force || !mNfceeRouteEnabled) {
            Log.d(TAG, "NFC-EE ON");
            mNfceeRouteEnabled = true;
            mDeviceHost.doSelectSecureElement();
        }
    } else {
        if (force ||  mNfceeRouteEnabled) {
            Log.d(TAG, "NFC-EE OFF");
            mNfceeRouteEnabled = false;
            mDeviceHost.doDeselectSecureElement();
        }
    }

此服务本身在本类其他部分启动并停止 。

问题回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签