Android : Method not being succesfully called

on Monday, September 29, 2014


My goals is to start a new Activity while a NFC card (DESFire in my case) is being detected. With using MIFARE SDK I received a few tutorials on how to write a program for NFC card to be detected.


This is the sample code example with some of my modifications in it:



public void onNewIntent(Intent intent){
libInstance.filterIntent(intent, new Inxpnfclibcallback(){

@Override
public void onDESFIRECardDetected(final DESFire desfire) {
// TODO Auto-generated method stub
ShowMessage("Im here", 'a');
objDesfire = desfire;
if (desfire == null) {
ShowMessage("Error!", 'a');
}
flag = true;
Log.i(TAG, "DESFire Card Detected");
try{
objDesfire.connectL4();
objDesfire.authenticate(AuthType.Native, 2, (byte) 0, 0, 0, null,
false);
objDesfire.setTimeout(2000);
objDesfire.format();
flag = true;


} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (GeneralSecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SmartCardException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
ShowMessage ("Error Occured!", 't');
}
}


I want to call this method while my Animation ends. I use "setAnimationListener". And "onAnimationEnd" I wrote this:



@Override
public void onAnimationEnd(Animation arg0) {
// TODO Auto-generated method stub
//startActivity(Main_activity);

MyClass myC = new MyClass();

logoMusic.stop();
Toast.makeText(IntroActivity.this, "Please tap your MIFARE Card", Toast.LENGTH_LONG).show();
myC.onNewIntent(getIntent());
if(flag == true){
Intent menuIntent = new Intent("com.example.nfcapp.MAINACT");
startActivity(menuIntent);
}
}


I tried to surround "onNewIntent" with a random class I created and then called it within "onAnimationEnd":



public class MyClass{ *...Inside here is the code from onNewIntent...*}


But this does not work. The Application runs without Errors. But when the Animation ends, the screen just remains the same, even if I tap the NFC card.


Can someone pleae help me how to fix this? I know I`m a beginner in Java, that's why I need your help.


0 comments:

Post a Comment