public void markerChanged(final String markerCode) { if (experience.get().getCallback() == null) { Intent intent = getIntent(); intent.putExtra("marker", markerCode); setResult(RESULT_OK, intent); finish(); } else { startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse(experience.get().getCallback().replace("{code}", markerCode)))); } }
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String artcode_scheme = getString(R.string.artcode_scan_scheme); Log.i(TAG, "New Intent: " + intent); if (intent.getStringExtra("experience") != null) { try { Gson gson = ExperienceParser.createParser(); Experience intentExperience = gson.fromJson(intent.getStringExtra("experience"), Experience.class); experience.set(intentExperience); } catch (Exception e) { Log.w(TAG, e.getMessage(), e); } } else if (artcode_scheme.equals(intent.getScheme())) { String data = intent.getData().toString(); Log.i(TAG, "Data: " + data); if (data.startsWith(artcode_scheme + ":")) // should! { data = data.substring(artcode_scheme.length() + 1); if (data.startsWith("//")) { data = data.substring(2); } } try { Log.i(TAG, "Data: " + data); data = URLDecoder.decode(data, "UTF-8"); Gson gson = ExperienceParser.createParser(); Experience intentExperience = gson.fromJson(data, Experience.class); experience.set(intentExperience); } catch (Exception e) { Log.e(TAG, "Error decoding experience " + data + ": " + e); finish(); } } }
@Override protected void onPause() { super.onPause(); stopCamera(); experience.removeListener(this); }
@Override public void onResume() { super.onResume(); startCamera(); experience.addListener(this); }