Page 178 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 178

NFC에  쓸지, NFC의  내용을  읽을지  정하는  버튼이  2개  있습니다.






            WriteActivity.java (NFC 태그  쓰기)



            NFC 태그에  텍스트를  쓰기  위한  액티비티. 대략  다음과  같습니다.



            먼저  NFC 관련  객체들을  생성해줍니다.
             public class WriteActivity extends ActionBarActivity {




                    private NfcAdapter nfcAdapter;
                    private PendingIntent pendingIntent;



                    public static final int TYPE_TEXT = 1;

                    public static final int TYPE_URI = 2;


                    EditText writeText;




                    @Override
                    protected void onCreate(Bundle savedInstanceState) {
                            super.onCreate(savedInstanceState);

                            setContentView(R.layout.activity_write);



                            if (savedInstanceState == null) {
                                    getSupportFragmentManager().beginTransaction()

                                                    .add(R.id.container,

                           new PlaceholderFragment()).commit();
                            }



                            writeText = (EditText) findViewById(R.id.writeText);



                            // NFC 관련  객체  생성
                            nfcAdapter = NfcAdapter.getDefaultAdapter(this);




                                                         -  171  -
   173   174   175   176   177   178   179   180   181   182   183