aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/AndroidManifest.xml10
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java11
2 files changed, 19 insertions, 2 deletions
diff --git a/main/AndroidManifest.xml b/main/AndroidManifest.xml
index c80add8..6217ad5 100644
--- a/main/AndroidManifest.xml
+++ b/main/AndroidManifest.xml
@@ -282,6 +282,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@@ -293,6 +294,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@@ -304,6 +306,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@@ -315,6 +318,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@@ -326,6 +330,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@@ -337,6 +342,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@@ -348,6 +354,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@@ -359,6 +366,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@@ -370,6 +378,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
@@ -381,6 +390,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index ef3823e..0866897 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -56,6 +56,7 @@ import cgeo.geocaching.utils.TextUtils;
import cgeo.geocaching.utils.UnknownTagsHandler;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.Charsets;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -84,6 +85,8 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
+import android.nfc.NdefMessage;
+import android.nfc.NfcAdapter;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@@ -182,13 +185,17 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
// get parameters
final Bundle extras = getIntent().getExtras();
- final Uri uri = getIntent().getData();
+ Uri uri = getIntent().getData();
// try to get data from extras
String name = null;
String geocode = null;
String guid = null;
- if (extras != null) {
+
+ if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
+ final NdefMessage msg = (NdefMessage) extras.getParcelableArray(NfcAdapter.EXTRA_NDEF_MESSAGES)[0];
+ uri = Uri.parse("http://" + new String(msg.getRecords()[0].getPayload(), Charsets.UTF_8));
+ } else if (extras != null) {
geocode = extras.getString(Intents.EXTRA_GEOCODE);
name = extras.getString(Intents.EXTRA_NAME);
guid = extras.getString(Intents.EXTRA_GUID);