Back to project page android-fragment-collection.
The source code is released under:
MIT License
If you think the Android project android-fragment-collection listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.vvakame.fragmentcollection.usage; /* w w w.j a v a 2 s .co m*/ import android.app.FragmentTransaction; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.Toast; import net.vvakame.fragmentcollection.AndroidBeamFragment; import java.io.UnsupportedEncodingException; import java.util.Date; public class MainActivity extends Activity implements AndroidBeamFragment.BeamActionCallbackPicker { final MainActivity self = this; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); { // AndroidBeamFragment??????????? FragmentTransaction tx = getFragmentManager().beginTransaction(); AndroidBeamFragment androidBeamFragment = new AndroidBeamFragment(); tx.add(androidBeamFragment, "beamFragment"); tx.commit(); } } @Override public AndroidBeamFragment.BeamActionCallback getBeamActionCallback() { return new BeamActionCallbackImpl(); } class BeamActionCallbackImpl implements AndroidBeamFragment.BeamActionCallback { @Override public void onNfcNotSupported() { Toast.makeText(self, "NFC?????????????????????????????", Toast.LENGTH_SHORT).show(); } @Override public void onNfcDisabled() { Toast.makeText(self, "NFC???OFF??????????????????????ON??????????????????????", Toast.LENGTH_SHORT).show(); } @Override public void onBeamReceived(byte[] msg) { String string = new String(msg); Toast.makeText(self, string, Toast.LENGTH_SHORT).show(); } @Override public byte[] onBeamSendPreprocess() { String str = new Date().toString(); try { return str.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { return "unexpected error occured".getBytes(); } } @Override public void onBeamSendComplete() { Toast.makeText(self, "?????", Toast.LENGTH_SHORT).show(); } } }