diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2015-01-06 19:30:59 +0100 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2015-01-06 19:30:59 +0100 |
commit | 2676f997e9b42f142926ec04285662d99ec068fc (patch) | |
tree | 972cb979bcbf798fdb7b7dd46dafbc789a60239b | |
parent | df9f6c4210349252ab5c9674a57112b187b5115b (diff) | |
parent | 57c41e935ea98738fec5bcdd79ccf854d98cb8af (diff) | |
download | cgeo-2676f997e9b42f142926ec04285662d99ec068fc.zip cgeo-2676f997e9b42f142926ec04285662d99ec068fc.tar.gz cgeo-2676f997e9b42f142926ec04285662d99ec068fc.tar.bz2 |
Merge branch 'issue-4590' (early part) into release
-rw-r--r-- | main/AndroidManifest.xml | 10 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 11 |
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); |