Skip to content

Commit

Permalink
Added NFC tag reading
Browse files Browse the repository at this point in the history
  • Loading branch information
michelefi committed Nov 27, 2013
1 parent 374c8ec commit 35a56d4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 8 additions & 3 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/com.google.developers.gdgfirenze.android" />
</intent-filter>
</activity>

<service
Expand All @@ -52,8 +56,9 @@
android:name="com.google.developers.gdgfirenze.android.NfcWriteActivity"
android:label="@string/title_activity_nfc_write" >
<intent-filter>
<action android:name="com.google.developers.gdgfirenze.android.WRITE_NFC" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="com.google.developers.gdgfirenze.android.WRITE_NFC" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
Expand Down
11 changes: 11 additions & 0 deletions src/com/google/developers/gdgfirenze/android/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
Expand All @@ -12,6 +13,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Toast;

public class MainActivity extends Activity implements
ActionBar.OnNavigationListener {
Expand Down Expand Up @@ -43,6 +45,15 @@ protected void onCreate(Bundle savedInstanceState) {
this);
}

public void onResume() {
super.onResume();
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
Toast toast = Toast.makeText(this, "NFC Tag Read",
Toast.LENGTH_SHORT);
toast.show();
}
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
// Restore the previously serialized current dropdown position.
Expand Down

0 comments on commit 35a56d4

Please sign in to comment.