-
-
Save TakashiSasaki/2892885 to your computer and use it in GitHub Desktop.
matsushige-nfc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Auto detect text files and perform LF normalization | |
* text=auto | |
# Custom for Visual Studio | |
*.cs diff=csharp | |
*.sln merge=union | |
*.csproj merge=union | |
*.vbproj merge=union | |
*.fsproj merge=union | |
*.dbproj merge=union | |
# Standard to msysgit | |
*.doc diff=astextplain | |
*.DOC diff=astextplain | |
*.docx diff=astextplain | |
*.DOCX diff=astextplain | |
*.dot diff=astextplain | |
*.DOT diff=astextplain | |
*.pdf diff=astextplain | |
*.PDF diff=astextplain | |
*.rtf diff=astextplain | |
*.RTF diff=astextplain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################# | |
## Eclipse | |
################# | |
gen/ | |
.metadata | |
bin/** | |
tmp/** | |
tmp/**/* | |
*.tmp | |
*.bak | |
*.swp | |
*~.nib | |
local.properties | |
.classpath | |
.settings/ | |
.loadpath | |
# External tool builders | |
.externalToolBuilders/ | |
# Locally stored "Eclipse launch configurations" | |
*.launch | |
# CDT-specific | |
.cproject | |
# PDT-specific | |
.buildpath | |
################# | |
## Visual Studio | |
################# | |
## Ignore Visual Studio temporary files, build results, and | |
## files generated by popular Visual Studio add-ons. | |
# User-specific files | |
*.suo | |
*.user | |
*.sln.docstates | |
# Build results | |
**/[Dd]ebug/ | |
**/[Rr]elease/ | |
*_i.c | |
*_p.c | |
*.ilk | |
*.meta | |
*.obj | |
*.pch | |
*.pdb | |
*.pgc | |
*.pgd | |
*.rsp | |
*.sbr | |
*.tlb | |
*.tli | |
*.tlh | |
*.tmp | |
*.vspscc | |
.builds | |
**/*.dotCover | |
## TODO: If you have NuGet Package Restore enabled, uncomment this | |
#**/packages/ | |
# Visual C++ cache files | |
ipch/ | |
*.aps | |
*.ncb | |
*.opensdf | |
*.sdf | |
# Visual Studio profiler | |
*.psess | |
*.vsp | |
# ReSharper is a .NET coding add-in | |
_ReSharper* | |
# Installshield output folder | |
[Ee]xpress | |
# DocProject is a documentation generator add-in | |
DocProject/buildhelp/ | |
DocProject/Help/*.HxT | |
DocProject/Help/*.HxC | |
DocProject/Help/*.hhc | |
DocProject/Help/*.hhk | |
DocProject/Help/*.hhp | |
DocProject/Help/Html2 | |
DocProject/Help/html | |
# Click-Once directory | |
publish | |
# Others | |
[Bb]in | |
[Oo]bj | |
sql | |
TestResults | |
*.Cache | |
ClientBin | |
stylecop.* | |
~$* | |
*.dbmdl | |
Generated_Code #added for RIA/Silverlight projects | |
# Backup & report files from converting an old project file to a newer | |
# Visual Studio version. Backup files are not needed, because we have git ;-) | |
_UpgradeReport_Files/ | |
Backup*/ | |
UpgradeLog*.XML | |
############ | |
## Windows | |
############ | |
# Windows image file caches | |
Thumbs.db | |
# Folder config file | |
Desktop.ini | |
############# | |
## Python | |
############# | |
*.py[co] | |
# Packages | |
*.egg | |
*.egg-info | |
dist | |
build | |
eggs | |
parts | |
bin | |
var | |
sdist | |
develop-eggs | |
.installed.cfg | |
# Installer logs | |
pip-log.txt | |
# Unit test / coverage reports | |
.coverage | |
.tox | |
#Translations | |
*.mo | |
#Mr Developer | |
.mr.developer.cfg | |
# Mac crap | |
.DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[submodule "src/com/gmail/takashi316/lib"] | |
path = src/com/gmail/takashi316/lib | |
url = https://github.com/TakashiSasaki/android-lib.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<projectDescription> | |
<name>matsushige-nfc</name> | |
<comment></comment> | |
<projects> | |
</projects> | |
<buildSpec> | |
<buildCommand> | |
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | |
<arguments> | |
</arguments> | |
</buildCommand> | |
<buildCommand> | |
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | |
<arguments> | |
</arguments> | |
</buildCommand> | |
<buildCommand> | |
<name>org.eclipse.jdt.core.javabuilder</name> | |
<arguments> | |
</arguments> | |
</buildCommand> | |
<buildCommand> | |
<name>com.android.ide.eclipse.adt.ApkBuilder</name> | |
<arguments> | |
</arguments> | |
</buildCommand> | |
</buildSpec> | |
<natures> | |
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | |
<nature>org.eclipse.jdt.core.javanature</nature> | |
</natures> | |
</projectDescription> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.gmail.matsushige" | |
android:versionCode="1" | |
android:versionName="1.0" > | |
<uses-sdk android:minSdkVersion="14" /> | |
<application | |
android:icon="@drawable/ic_launcher" | |
android:label="@string/app_name"> | |
<activity | |
android:name=".NFC1Activity" | |
android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTop"> | |
<intent-filter> | |
<action android:name="android.nfc.action.TAG_DISCOVERED" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
</intent-filter><intent-filter> | |
<action android:name="android.nfc.action.NDEF_DISCOVERED" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
<data android:mimeType="*/*"/> | |
</intent-filter> | |
<intent-filter> | |
<action android:name="android.nfc.action.TECH_DISCOVERED" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
</intent-filter> | |
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/filter_nfc" /><intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
<activity android:name="LogActivity"></activity> | |
<activity android:name="UsersActivity"></activity> | |
<activity android:name="com.gmail.takashi316.sandbox.HelloAndroidActivity"></activity> | |
</application> | |
</manifest> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.matsushige; | |
import android.os.Bundle; | |
import com.gmail.takashi316.lib.android.activity.SmartActivity; | |
public class BaseActivity extends SmartActivity { | |
@SuppressWarnings("boxing") | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
this.addActivityClass(R.id.itemLog, LogActivity.class); | |
this.addActivityClass(R.id.itemMain, NFC1Activity.class); | |
this.addActivityClass(R.id.itemUsers, UsersActivity.class); | |
this.setExitItemId(R.id.itemExit); | |
this.setMenuResourceId(R.menu.menu); | |
super.onCreate(savedInstanceState); | |
}// onCreate | |
@Override | |
protected void onRestart() { | |
// TODO Auto-generated method stub | |
super.onRestart(); | |
} | |
}// BasicActivity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.matsushige; | |
import android.content.ContentValues; | |
import android.content.Context; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.database.sqlite.SQLiteDatabase.CursorFactory; | |
import android.database.sqlite.SQLiteOpenHelper; | |
public class DatabaseHelper extends SQLiteOpenHelper { | |
public DatabaseHelper(Context context) { | |
super(context,"NFC1.sqlite", null, 1); | |
// TODO Auto-generated constructor stub | |
} | |
@Override | |
public void onCreate(SQLiteDatabase db) { | |
// TODO Auto-generated method stub | |
db.execSQL("CREATE TABLE touch(" | |
+"_id INTEGER PRIMARY KEY AUTOINCREMENT," | |
+"type TEXT, ID TEXT, timestamp INTEGER);"); | |
} | |
@Override | |
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) { | |
// TODO Auto-generated method stub | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> | |
<tech-list> | |
<tech>android.nfc.tech.NfcF</tech> | |
</tech-list> | |
<tech-list> | |
<tech>android.nfc.tech.NfcB</tech> | |
</tech-list> | |
<tech-list> | |
<tech>android.nfc.tech.NfcA</tech> | |
</tech-list> | |
<tech-list> | |
<tech>android.nfc.tech.Ndef</tech> | |
</tech-list> | |
</resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:orientation="vertical" > | |
<TextView | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/hello" | |
android:id="@+id/textViewHello"/> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.takashi316.sandbox; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import com.gmail.matsushige.R; | |
public class HelloAndroidActivity extends Activity { | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.hello_main); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" > | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.matsushige; | |
import android.os.Bundle; | |
public class LogActivity extends BaseActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
setActivityLayoutId(R.layout.log_activity); | |
super.onCreate(savedInstanceState); | |
}// onCreate | |
}// LogActivity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:orientation="vertical" > | |
<TextView | |
android:id="@+id/textView1" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="waiting" /> | |
<TextView | |
android:id="@+id/textView2" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="waiting" /> | |
<TextView | |
android:id="@+id/textView3" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="waiting" /> | |
<TextView | |
android:id="@+id/textView4" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="waiting" /> | |
<TextView | |
android:id="@+id/textView5" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="waiting" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" > | |
<Button | |
android:id="@+id/buttonActionTag" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="A. TAG" /> | |
<Button | |
android:id="@+id/buttonActionNdef" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="A. NDEF" /> | |
<Button | |
android:id="@+id/buttonActionTech" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="A. TECH" /> | |
<Button | |
android:id="@+id/buttonClear" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Clear" /> | |
</LinearLayout> | |
<Button | |
android:id="@+id/buttonCheck" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="Check" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="vertical" > | |
<ScrollView | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" > | |
<TextView | |
android:id="@+id/textViewTouch" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:scrollbarAlwaysDrawVerticalTrack="true" | |
android:scrollbars="vertical" | |
android:text="TextView" /> | |
</ScrollView> | |
</LinearLayout> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.matsushige; | |
import java.util.Calendar; | |
import android.app.AlertDialog; | |
import android.nfc.*; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.*; | |
import android.content.ContentValues; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.database.Cursor; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.graphics.Color; | |
import android.nfc.tech.*; | |
public class NFC1Activity extends BaseActivity { | |
/** Called when the activity is first created. */ | |
private String judge = null; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
setActivityLayoutId(R.layout.main); | |
super.onCreate(savedInstanceState); | |
// SQLiteDatabase db = (new DatabaseHelper(this)).getWritableDatabase(); | |
// db.close(); | |
button(R.id.buttonClear).setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
button(R.id.buttonActionNdef).setBackgroundColor(Color.GRAY); | |
button(R.id.buttonActionTag).setBackgroundColor(Color.GRAY); | |
button(R.id.buttonActionTech).setBackgroundColor(Color.GRAY); | |
textView(R.id.textView1).setText("waiting"); | |
textView(R.id.textView2).setText("waiting"); | |
textView(R.id.textView3).setText("waiting"); | |
textView(R.id.textView4).setText("waiting"); | |
textView(R.id.textView5).setText("waiting"); | |
}// onClick | |
});// setOnClickListener | |
button(R.id.buttonCheck).setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
openUsers(); | |
}// onClick | |
});// setOnClickListener | |
}// onCreate | |
@Override | |
public void onResume() { | |
String action = getIntent().getAction(); | |
if (action == null) { | |
Log.d("NFC1Activity#onResume", "null"); | |
super.onResume(); | |
return; | |
} | |
Log.d("NFC1Activity#onResume", action); | |
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { | |
actionNdefDiscovered(); | |
} else if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) { | |
Log.d("NFC1Activity", "TECH_DISCOVERED"); | |
actionTechDiscovered(); | |
} else if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) { | |
actionTagDiscovered(); | |
}// if | |
super.onResume(); | |
} // onResume | |
private void actionTechDiscovered() { | |
button(R.id.buttonActionTech).setBackgroundColor(Color.RED); | |
readNfc(); | |
} | |
private void actionNdefDiscovered() { | |
button(R.id.buttonActionNdef).setBackgroundColor(Color.RED); | |
readNfc(); | |
} | |
private void actionTagDiscovered() { | |
button(R.id.buttonActionTag).setBackgroundColor(Color.RED); | |
readNfc(); | |
}// actionTagDiscovered | |
public void readNfc() { | |
Intent intent = getIntent(); | |
byte[] id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID); | |
Tag tag = (Tag) intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); | |
String idD = "ID : " + hex(id); | |
textView(R.id.textView1).setText(idD); | |
String[] techList = tag.getTechList(); | |
String tech = "TechList : "; | |
for (String w : techList) { | |
tech += w; | |
}// for | |
textView(R.id.textView2).setText(tech); | |
if (tech.contains("NfcF")) { | |
// TODO: 要検討 | |
recordId("NfcF", hex(id).toUpperCase()); | |
NfcF techF = NfcF.get(tag); | |
byte[] mc = techF.getManufacturer(); | |
String mcD = "ManufactureCode : " + hex(mc); | |
textView(R.id.textView3).setText(mcD); | |
byte[] sc = techF.getSystemCode(); | |
String scD = "SystemCode : " + hex(sc); | |
textView(R.id.textView4).setText(scD); | |
}// if <NfcF> | |
else if (tech.contains("NfcB")) { | |
// TODO: 要検討 | |
recordId("NfcB", hex(id).toUpperCase()); | |
NfcB nfcB = NfcB.get(tag); | |
byte[] ad = nfcB.getApplicationData(); | |
String adD = "ApplicationData : " + hex(ad); | |
textView(R.id.textView3).setText(adD); | |
byte[] pi = nfcB.getProtocolInfo(); | |
String piD = "ProtocolInfo : " + hex(pi); | |
textView(R.id.textView4).setText(piD); | |
if (tech.contains("IsoDep")) { | |
IsoDep isoDep = IsoDep.get(tag); | |
byte[] hlr = isoDep.getHiLayerResponse(); | |
String hlrD = "HiLayerResponse : " + hex(hlr); | |
textView(R.id.textView5).setText(hlrD); // 免許では読めなかった | |
}// if <IsoDep> | |
}// else if <NfcB> | |
else if (tech.contains("NfcA")) { | |
// TODO: 要検討 | |
recordId("NfcA", hex(id).toUpperCase()); | |
NfcA nfcA = NfcA.get(tag); | |
byte[] at = nfcA.getAtqa(); | |
String atD = "ATQA/SENS_RES : " + hex(at); | |
textView(R.id.textView3).setText(atD); | |
short sak = nfcA.getSak(); | |
String sakD = String.format("SAK : " + "%02x", sak); | |
textView(R.id.textView4).setText(sakD); | |
if (tech.contains("Classic")) { | |
MifareClassic mifareClassic = MifareClassic.get(tag); | |
int size = mifareClassic.getSize(); | |
String sizeD = Integer.toString(size); | |
int sector = mifareClassic.getSectorCount(); | |
String sectorD = Integer.toString(sector); | |
int block = mifareClassic.getBlockCount(); | |
String blockD = Integer.toString(block); | |
textView(R.id.textView5).setText( | |
"MemorySize : " + sizeD + "\nSecterCount : " + sectorD | |
+ "\nBlockCount : " + blockD); | |
}// if <MifareClassic> | |
}// else if <NfcA> | |
else { | |
textView(R.id.textView3).setText("NOT READ"); | |
}// else | |
}// readNfc | |
private void recordId(String type, String ID) { | |
long timestamp = Calendar.getInstance().getTimeInMillis(); | |
ContentValues cv = new ContentValues(); | |
cv.put("timestamp", timestamp); | |
cv.put("type", type); | |
cv.put("ID", ID); | |
SQLiteDatabase db = (new DatabaseHelper(this)).getWritableDatabase(); | |
db.insert("touch", null, cv); | |
db.close(); | |
db = (new DatabaseHelper(this)).getReadableDatabase(); | |
Cursor c = db.query("touch", null, null, null, null, null, | |
"timestamp desc"); | |
// Log.d("NFC1Activity", "" + c.getCount()); | |
String s = ""; | |
c.moveToFirst(); | |
for (int i = 0; i < c.getCount(); ++i) { | |
long _id = c.getLong(c.getColumnIndex("_id")); | |
String type_ = c.getString(c.getColumnIndex("type")); | |
String ID_ = c.getString(c.getColumnIndex("ID")); | |
long timestamp_ = c.getLong(c.getColumnIndex("timestamp")); | |
s += _id + " " + type_ + " " + ID_ + " " + timestamp_ + "\n"; | |
c.moveToNext(); | |
}// for | |
((TextView) (findViewById(R.id.textViewTouch))).setText(s); | |
db.close(); | |
SQLiteDatabase users = (new UsersDatabaseHelper(this)) | |
.getReadableDatabase(); | |
String where = "type = ?"; | |
String[] where_arg = { type }; | |
Cursor cursor = users.query("users", null, where, where_arg, null, | |
null, null); | |
/** 一致するtypeを確認 */ | |
this.judge = null; | |
while (cursor.moveToNext()) { | |
String idre = cursor.getString(cursor.getColumnIndex("id")); | |
if (ID.equals(idre)) { | |
/** 一致するidを確認 */ | |
this.judge = cursor.getString(cursor | |
.getColumnIndex("user_name")); | |
/** judgeにuser_nameを代入 */ | |
}// if | |
}// while | |
String mess = ""; | |
if (this.judge != null) { | |
/** judgeに値が入っているか確認 */ | |
mess = "こんにちは、" + this.judge + " さん"; | |
} else { | |
mess = "登録されていないカードです。"; | |
}// else | |
new AlertDialog.Builder(this).setTitle("結果").setMessage(mess) | |
.setNeutralButton("OK", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dlg, int sumthin) { | |
// 何もしない | |
} | |
}).show(); | |
Log.d("Nfc1Activity", "dialog_out"); | |
users.close(); | |
}// recordId | |
public static String hex(byte[] data) { | |
String hexText = ""; | |
for (byte v : data) { | |
hexText += String.format("%02x", new Object[] { v }); | |
}// for | |
return hexText; | |
}// hex | |
public void openUsers() { | |
SQLiteDatabase usersData = (new UsersDatabaseHelper(this)) | |
.getReadableDatabase(); | |
Cursor c = usersData.query("users", null, null, null, null, null, null); | |
String s = ""; | |
c.moveToFirst(); | |
for (int i = 0; i < c.getCount(); ++i) { | |
long _id = c.getLong(c.getColumnIndex("_id")); | |
String type_ = c.getString(c.getColumnIndex("type")); | |
String ID_ = c.getString(c.getColumnIndex("id")); | |
String name_ = c.getString(c.getColumnIndex("user_name")); | |
s += _id + " " + type_ + " " + ID_ + " " + name_ + "\n"; | |
c.moveToNext(); | |
}// for | |
((TextView) (findViewById(R.id.textViewTouch))).setText(s); | |
usersData.close(); | |
}// openUsers | |
}// Nfc1Activity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To enable ProGuard in your project, edit project.properties | |
# to define the proguard.config property as described in that file. | |
# | |
# Add project specific ProGuard rules here. | |
# By default, the flags in this file are appended to flags specified | |
# in ${sdk.dir}/tools/proguard/proguard-android.txt | |
# You can edit the include path and order by changing the ProGuard | |
# include property in project.properties. | |
# | |
# For more details, see | |
# http://developer.android.com/guide/developing/tools/proguard.html | |
# Add any project specific keep options here: | |
# If your project uses WebView with JS, uncomment the following | |
# and specify the fully qualified class name to the JavaScript interface | |
# class: | |
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | |
# public *; | |
#} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is automatically generated by Android Tools. | |
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | |
# | |
# This file must be checked in Version Control Systems. | |
# | |
# To customize properties used by the Ant build system edit | |
# "ant.properties", and override values to adapt the script to your | |
# project structure. | |
# | |
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | |
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt | |
# Project target. | |
target=android-15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<string name="hello">Hello World, NFC1Activity!</string> | |
<string name="app_name">NFC1</string> | |
</resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="wrap_content" | |
android:layout_height="match_parent" | |
android:orientation="vertical" > | |
<ListView | |
android:id="@+id/listViewUsers" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" > | |
</ListView> | |
<Button | |
android:id="@+id/buttonResetUsers" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="Button" /> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.matsushige; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.os.Bundle; | |
public class UsersActivity extends BaseActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
//setActivityLayoutId(R.layout.users_activity); | |
//setFragmentClass(UsersFragment.class); | |
//setFragmentContainer(R.id.linearLayoutUsers); | |
super.onCreate(savedInstanceState); | |
}// onCreate | |
void resetUser() { | |
SQLiteDatabase dbUsers = (new UsersDatabaseHelper(this)) | |
.getWritableDatabase(); | |
dbUsers.close(); | |
}// resetUser | |
}// UsersActivity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.matsushige; | |
import android.content.ContentValues; | |
import android.content.Context; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.database.sqlite.SQLiteOpenHelper; | |
public class UsersDatabaseHelper extends SQLiteOpenHelper { | |
public UsersDatabaseHelper(Context context) { | |
super(context, "NFC1.2.sqlite", null, 1); | |
// TODO Auto-generated constructor stub | |
} | |
@Override | |
public void onCreate(SQLiteDatabase db) { | |
// TODO Auto-generated method stub | |
db.execSQL("CREATE TABLE users(" + | |
"_id INTEGER PRIMARY KEY AUTOINCREMENT," + | |
"type TEXT, id TEXT, user_name TEXT, math INTEGER)"); | |
ContentValues cv = new ContentValues(); | |
cv.put("type", "NfcF"); | |
cv.put("id", "0115E5005B0BB104"); | |
cv.put("user_name", "学生証"); | |
db.insert("users", null, cv); | |
cv.put("type","NfcB"); | |
cv.put("id", "91D3B724"); | |
cv.put("user_name", "免許証"); | |
db.insert("users", null, cv); | |
cv.put("type", "NfcA"); | |
cv.put("id", "8532D18C"); | |
cv.put("user_name", "taspo"); | |
db.insert("users", null, cv); | |
cv.put("type","NfcF"); | |
cv.put("id", "01130200F10C3B01"); | |
cv.put("user_name", "都築 伸二"); | |
db.insert("users", null, cv); | |
cv.put("type", "NfcA"); | |
cv.put("id", "14dd4d42"); | |
cv.put("user_name", "Takashi SASAKI ubikey"); | |
db.insert("users", null, cv); | |
} | |
@Override | |
public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) { | |
// TODO Auto-generated method stub | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.matsushige; | |
import com.gmail.takashi316.lib.android.activity.BasicFragment; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.os.Bundle; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.view.ViewGroup; | |
public class UsersFragment extends BasicFragment { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
this.setFragmentLayoutId(R.layout.users_fragment); | |
super.onCreate(savedInstanceState); | |
}// onCreate | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
Bundle savedInstanceState) { | |
View view = super.onCreateView(inflater, container, savedInstanceState); | |
this.setButtonOnClickListener(R.id.buttonResetUsers, | |
new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
UsersDatabaseHelper users_database_helper = new UsersDatabaseHelper( | |
v.getContext()); | |
SQLiteDatabase sqlite_database = users_database_helper | |
.getWritableDatabase(); | |
sqlite_database.close(); | |
}// onClick | |
});// onClickListener | |
return view; | |
}// onCreateView | |
}// UserFragment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment