| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| package io.v.example.vbeam.vbeamexample; |
| |
| import android.os.Bundle; |
| import android.support.design.widget.FloatingActionButton; |
| import android.support.design.widget.Snackbar; |
| import android.support.v7.app.AppCompatActivity; |
| import android.support.v7.widget.Toolbar; |
| import android.view.View; |
| import android.widget.Toast; |
| |
| import java.nio.charset.Charset; |
| |
| import io.v.android.v23.VBeam; |
| |
| public class GotBeamActivity extends AppCompatActivity { |
| |
| @Override |
| protected void onCreate(Bundle savedInstanceState) { |
| super.onCreate(savedInstanceState); |
| setContentView(R.layout.activity_got_beam); |
| Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); |
| setSupportActionBar(toolbar); |
| |
| FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); |
| fab.setOnClickListener(new View.OnClickListener() { |
| @Override |
| public void onClick(View view) { |
| Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) |
| .setAction("Action", null).show(); |
| } |
| }); |
| } |
| |
| @Override |
| protected void onResume() { |
| super.onResume(); |
| System.out.println("GotBeamActivity.onResume("+getIntent().getAction()+")"); |
| byte[] payload = VBeam.getBeamPayload(getIntent()); |
| if (payload != null) { |
| Toast.makeText(this, new String(payload, Charset.forName("utf-8")), Toast.LENGTH_LONG); |
| } |
| } |
| } |