blob: f7ee1612e81211b01aa285b178e27afee415c59d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright (C) 2018 Governikus GmbH & Co. KG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
package org.qtproject.qt.android.nfc;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.nfc.NfcAdapter;
public class QtNfcBroadcastReceiver extends BroadcastReceiver
{
private Context qtContext;
public QtNfcBroadcastReceiver(Context context)
{
qtContext = context;
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
qtContext.registerReceiver(this, filter);
}
public void unregisterReceiver()
{
qtContext.unregisterReceiver(this);
}
public void onReceive(Context context, Intent intent)
{
final int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_OFF);
jniOnReceive(state);
}
public native void jniOnReceive(int state);
}
|