Enable/Disable NFC with ADB command

2019-01-27 22:03发布

Is there any way to disable/enable NFC via ADB shell commands?

I found one answer here.

What I tried from the above link:

# Enable NFC
service call nfc 5

# Disable NFC
service call nfc 4 

but it's not working.

Any help appreciated. Thanks.

6条回答
Bombasti
2楼-- · 2019-01-27 22:29

For Android Version > 7, please use following -

# Enable NFC
service call nfc 7
# Disable NFC
service call nfc 6

Verified on 7.1.1... Should work for atleast 7.x

查看更多
老娘就宠你
3楼-- · 2019-01-27 22:30

Please try this

# Enable NFC
service call nfc 6
# Disable NFC
service call nfc 5 

please check here in slide no 32

查看更多
我想做一个坏孩纸
4楼-- · 2019-01-27 22:35

# Disable NFC

service call nfc 7

Verified for Android 8.0

Cheers!

查看更多
5楼-- · 2019-01-27 22:45

In your DDMS of eclipse or using logfilter or any runtime log capturing tool, you need to get the process ID of your NFCService. Then you can kill or stop that process by giving the process ID.

查看更多
Anthone
6楼-- · 2019-01-27 22:48

System services' method codes may vary with Android versions. Therefore, before making a service's method call browse the AOSP sources.

Below is a summary of the NFC's enable/disable calls up to Android 5.1.1. Also keep in mind that (in the sources)

int FIRST_CALL_TRANSACTION  = 0x00000001

,i.e. equals to 1.

Android 4.4 - Android 5.1.1:

# Disable NFC
service call nfc 5
# Enable NFC
service call nfc 6

Android 4.0.1 - Android 4.3.1:

# Disable NFC
service call nfc 4
# Enable NFC
service call nfc 5

Android 2.3.4 - Android 2.3.7:

# Disable NFC
service call nfc 18
# Enable NFC
service call nfc 19

Android 2.3.3:

# Disable NFC
service call nfc 20
# Enable NFC
service call nfc 21

Android 2.3.2:

# Disable NFC
service call nfc 13
# Enable NFC
service call nfc 14

To check the status of the NFC service use the dumpsys command:

dumpsys nfc
查看更多
我欲成王,谁敢阻挡
7楼-- · 2019-01-27 22:48

I don't know why no one has posted this already

svc nfc <enable|disable>

Works perfectly

Edit: Requires > Android 6.0

查看更多
登录 后发表回答