Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hds
flexin
android-app
Commits
cb1df112
Commit
cb1df112
authored
Dec 07, 2017
by
Nastuzzi Samy
Browse files
NFC leak fixed
Stop to listen the NFC when the application is not running
parent
973fb138
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/fr/utc/simde/jessy/NFCActivity.java
View file @
cb1df112
...
...
@@ -29,7 +29,7 @@ public abstract class NFCActivity extends Activity {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
NFCAdapter
=
NfcAdapter
.
getDefaultAdapter
(
getApplicationContext
()
);
NFCAdapter
=
NfcAdapter
.
getDefaultAdapter
(
this
);
NFCAlertDialog
=
new
AlertDialog
.
Builder
(
this
);
if
(
NFCAdapter
==
null
)
{
...
...
@@ -65,6 +65,9 @@ public abstract class NFCActivity extends Activity {
if
(!
NFCAdapter
.
isEnabled
())
enableNFCDialog
();
IntentFilter
filter
=
new
IntentFilter
(
NfcAdapter
.
ACTION_ADAPTER_STATE_CHANGED
);
this
.
registerReceiver
(
NFCReceiver
,
filter
);
}
}
...
...
@@ -72,15 +75,17 @@ public abstract class NFCActivity extends Activity {
protected
void
onPause
()
{
super
.
onPause
();
if
(
identifierIsAvailable
())
NFCAdapter
.
disableForegroundDispatch
(
this
);
NFCAdapter
=
NfcAdapter
.
getDefaultAdapter
(
this
);
NFCAdapter
.
disableForegroundDispatch
(
this
);
this
.
unregisterReceiver
(
NFCReceiver
);
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
this
.
unregisterReceiver
(
NFCReceiver
);
try
{
this
.
unregisterReceiver
(
NFCReceiver
);
}
catch
(
Exception
e
)
{}
}
protected
abstract
void
onIdentification
(
final
String
badgeId
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment