P2P NFC를 사용하는 Android 앱이 있습니다. NFC는 작동하지만 시작하려면 기기를 두 번 탭해야합니다. 내 애플 리케이션을 디버깅하고 장치를 탭하면 createNdefMessage 함수가 호출되지만 JavaBinder에서는 예외가 발생합니다. 실행 모드에서는 충돌이 발생하지 않지만 NFC를 시작하려면 장치를 두 번 탭해야합니다.Android NFC 스로 잉 예외
NFC 전에는 파일 선택자를 호출하여 전송할 파일을 선택합니다. 여기 내 코드는
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// INFO TEXTVIEW
mInfoText = (TextView) findViewById(R.id.info_text_view);
// FILE SELECTOR BUTTON
mStartActivityButton = (Button)findViewById(R.id.start_file_picker_button);
mStartActivityButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.start_file_picker_button:
// Create a new Intent for the file picker activity
Intent intent = new Intent(getApplicationContext(), FilePickerActivity.class);
// Start the activity
startActivityForResult(intent, REQUEST_PICK_FILE);
break;
}
}
});
// CHECK FOR AVAILABLE NFC ADAPTOR
mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (mNfcAdapter == null) {
mInfoText.setText("NFC is not available on this device.");
} else {
// Register callback to set NDEF message
mNfcAdapter.setNdefPushMessageCallback(this, this);
// Register callback to listen for message-sent success
mNfcAdapter.setOnNdefPushCompleteCallback(this, this);
}
}
createNdefMessage을 한 OnCreate입니다
내가이 개 의도를 겪고 있기 때문에 내 애플은mInfoText.setTextColor(Color.WHITE);
에서 예외가 그 것이다 스루
public NdefMessage createNdefMessage(NfcEvent event) {
Time time = new Time();
time.setToNow();
mInfoText.setTextColor(Color.WHITE);
mInfoText.setText("File Transfer In Progress ...");
NdefMessage msg = new NdefMessage(NdefRecord.createMime(
"application/com.example.android.beam", text.getBytes()));
return msg;
}
?
stacktrace를 호출하십시오. – njzk2