File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
app/src/main/java/com/termux/api/apis Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 19
19
import com .termux .api .util .ResultReturner ;
20
20
import com .termux .shared .logger .Logger ;
21
21
22
+ import java .nio .charset .StandardCharsets ;
23
+
22
24
public class NfcAPI {
23
25
24
26
private static final String LOG_TAG = "NfcAPI" ;
@@ -165,6 +167,9 @@ public void writeJson(JsonWriter out) throws Exception {
165
167
case "full" :
166
168
readFullNDEFTag (intent ,out );
167
169
break ;
170
+ case "id" :
171
+ readNDEFID (intent ,out );
172
+ break ;
168
173
case "noData" :
169
174
readNDEFTag (intent ,out );
170
175
break ;
@@ -245,6 +250,18 @@ public void readNDEFTag(Intent intent, JsonWriter out) throws Exception {
245
250
}
246
251
}
247
252
253
+ public void readNDEFID (Intent intent , JsonWriter out ) throws Exception {
254
+ NfcAdapter adapter = NfcAdapter .getDefaultAdapter (this );
255
+ byte [] tag_id = intent .getByteArrayExtra (NfcAdapter .EXTRA_ID );
256
+ out .beginObject ();
257
+ StringBuilder sb = new StringBuilder ();
258
+ for (byte b : tag_id ) {
259
+ sb .append (String .format ("%02X" , b ));
260
+ }
261
+ out .name ("card_id" ).value (sb .toString ());
262
+ out .endObject ();
263
+ }
264
+
248
265
public void readFullNDEFTag (Intent intent , JsonWriter out ) throws Exception {
249
266
Logger .logVerbose (LOG_TAG , "readFullNDEFTag" );
250
267
You can’t perform that action at this time.
0 commit comments