회사에서 개발중인 프로그램에 nfc 기능이 붙어서 이번에 기능을 추가 했는데요
다른 기능은 다 문제가 없는데
nfc 태그로 액티비티를 최초 실행했을때
onNewIntent(Intent intent) 가 호출되야하는데
onCreate(Bundle bd) 가 호출되면서 액티비티가 새로 뜨네요
최초 실행 됬던 액티비티는 살아있구요
그 뒤로 실행된 두번째 액티비티에서는 제대로 동작합니다.
상용되있는 앱이라 이건 치명적인 오류인데
제가 봤을때는 enableForegroundDispatch 할때 intent를 잘 못 넘겨주는거 같은데...
이걸 해결하는 방법이 없을까요?
아래는 enableForegroundDispatch 부분입니다.
private void enableForegroundDispatch() {
Log.d(TAG, "enableForegroundDispatch");
NfcAdapter nfcAp = NfcAdapter.getDefaultAdapter(this);
Intent intent = new Intent(this, getClass());
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
String[][] filter = new String[][] { new String[] { "android.nfc.tech.NfcF" } };
try{
nfcAp.enableForegroundDispatch(this, pi, null, filter);
}catch(Exception e){
Log.e(TAG, "enableForegoundDispatch error");
e.printStackTrace();
}