Hello everyone, i'm currently trying to wrap a library for a POS system, the device has a built in app which makes it really easy to do all the Transactions between customer and banks, the app is called using a number of intents, they have provided a Class which defines all the actions and extra data for the intents.
My question is, i am trying to get the results after a transaction has been performed, i have the following code which i took from one of @Erel's tutorials but all i get is the following:
the code i am using is this:
The code from the TransactionController class for the performBalanceInquiry is the following:
does anyone know why the result is null, does my code look fine?
Does anyone have any suggestions?
Thanks,
Walter
My question is, i am trying to get the results after a transaction has been performed, i have the following code which i took from one of @Erel's tutorials but all i get is the following:
onActivityResult wii null
the code i am using is this:
B4X:
public void PerformBalanceInquiry(BA ba) {
//This line is calling the performBalanceInquiry defined in the TransactionController class which is made up of an intent.
mTransactionController.performBalanceInquiry();
ion = new IOnActivityResult() {
@Override
public void ResultArrived(int arg0, Intent arg1) {
// TODO Auto-generated method stub
BA.Log("ResultArrived: " + arg0 + " --- " + arg1.getDataString());
}
};
try {
ba.startActivityForResult(ion, null); //<-- passing null instead of an intent
} catch (NullPointerException npe) {
//required...
// mba.setLastException(npe);
BA.Log("nullpointerexception: " + npe.getMessage().toString());
}
// BA.SharedProcessBA sba = mba.sharedProcessBA;
BA.SharedProcessBA sba = ba.processBA.sharedProcessBA;
try {
Field f = sba.getClass().getDeclaredField("onActivityResultMap");
f.setAccessible(true);
if (f.get(sba) == null) {
f.set(sba, new HashMap<Integer, WeakReference<IOnActivityResult>>());
@SuppressWarnings("unchecked")
HashMap<Integer, WeakReference<IOnActivityResult>> onActivityResultMap = (HashMap<Integer, WeakReference<IOnActivityResult>>) f.get(sba);
BA.Log("onActivityResultMap: " + onActivityResultMap.size());
}
// int requestCode = f.getInt(sba) - 1;
// BA.Log("requestcode: " + requestCode);
//requestCode holds the value that should be used to send the intent.
} catch (Exception e) {
throw new RuntimeException(e);
}
}
The code from the TransactionController class for the performBalanceInquiry is the following:
B4X:
public void performBalanceInquiry() {
Intent intent = new Intent(ACTION_BALANCE_INQUIRY);
intent.putExtra("dummy", "dummy");
intent.putExtra(KEY_AUTO_PRINT, mAutoPrint);
intent.setType("text/plain");
BA.Log("gettingpackage name: " + mActivity.getPackageManager().toString());
if(intent.resolveActivity(mActivity.getPackageManager()) != null) {
mActivity.startActivityForResult(intent, REQUEST_CODE_BALANCE_INQUIRY);
BA.Log("After BalanceInquiry: " + REQUEST_CODE_BALANCE_INQUIRY);
}
else {
// Toast.makeText(mActivity, mActivity.getString(R.string.no_activity_handle), Toast.LENGTH_SHORT).show();
BA.Log("No Activity_Handle");
}
}
does anyone know why the result is null, does my code look fine?
Does anyone have any suggestions?
Thanks,
Walter