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

Intent intent = new Intent(this, getClass())

                                            .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

                            pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
                    }





                    // ... 생략



            NFC 태그를  스캔하면  onNewIntent() 메소드가  작동합니다.

                    // NFC 태그  스캔시  호출되는  메소드

                    @Override
                    protected void onNewIntent(Intent intent) {
                            super.onNewIntent(intent);




                            if (intent != null) {
                                    processTag(intent); // processTag 메소드  호출
                            }

                    }



            그  후  processTag() 메소드가  수행된  후
                    // onNewIntent 메소드  수행  후  호출되는  메소드

                    private void processTag(Intent intent) {
                            // EditText에  입력된  값을  가져옴

                            String s = writeText.getText().toString();



                            // 감지된  태그를  가리키는  객체

                            Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);


                            // 아무것도  입력받지  않으면  태그에  쓰지  않음

                            if (s.equals("")) {

                                    Toast.makeText(getApplicationContext(),
                                    "내용을  입력해주세요.", 1000).show();
                            }




                                                         -  172  -
   174   175   176   177   178   179   180   181   182   183   184