Xamarin app crashes when using VB.Net Now() or Today() - android

I have an object Shift with a property DateAndTime as Date.
When I try to set this property using Now() the VS debugger pops up an error
System.TypeLoadException: 'Could not resolve type with token 0100006b from typeref (expected class 'Microsoft.VisualBasic.DateAndTime' in assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')'
If I hard code a date e.g. #2022-12-25 3:10 PM# all is fine. What does Xamarin expect?

You shouldn't really be using those in any VB code, never mind a Xamarin app. Don't use VB Runtime functions (methods from modules in the Microsoft.VisualBasic namespace) when there are equivalent or better options that are not VB-specific. In this case, use the Date.Now and Date.Today properties, exactly as any C# developer would.
Note that Date is a VB data type that maps to the .NET DateTime structure. You can use either in your code but, if you use Integer rather than Int32 then you should be using Date rather than DateTime too.

Related

Using JCESecurityModule on Android device

While trying to carry out an encryption and decryption process on an Android environment, i have the below log.
com.s.sdk.security.SMException: Error loading Local Master Keys, file:
"/cfg/lmktest.lmk" does not exist. Please specify a valid LMK file, or
rebuild a new one. 09-21 11:56:31.792 16182-16182/com.mpos.sdk
W/System.err: at
com.s.sdk.security.jceadapter.JCESecurityModule.init(JCESecurityModule.java:1785)
09-21 11:56:31.792 16182-16182/com.mpos.sdk W/System.err: at
com.s.sdk.security.jceadapter.JCESecurityModule.(JCESecurityModule.java:159)
The reason why I will want to make use of JPOS is simply because I will want to carry out a financial transaction, which will be used in packaging my message.
For the encryption and decryption of data, I am to make use of this JCESecurityModule which works well on other platform, but not on the android OS.
NOTE: The file location in my android studio is app/cfg/test.lmk
I was able to get this file from the JPOS-master on github found in the jPOS-master\jPOS-master\jpos\src\test\resources\org\jpos\security
i.e the lmk-test
which was been used this way
JCESecurityModule sm = new JCESecurityModule("app/cfg/test.lmk");
I have also tried rebuilidng the lmk file, using the below method
public JCESecurityModule (String lmkFile) throws SMException
{
init(null, lmkFile, true);
}
which can be found in the JCESecurityModule class (JPOS)
was still having same issue in loading the lmk file
Thanks
For the sake of completeness, this was also asked on the jPOS's Google Group, and discussed there. https://groups.google.com/forum/#!topic/jpos-users/X3r_PX7lgd4
The encryption was done by a device which is to be connected to a mobile phone to carrying out transactions, but the device makers actually did it this way to provide end to end encryption which you are circumventing. You don't need jpos in the device. You need it at your centrally deployed servers, where you would use real HSMs.
by Victor Salaman
in JPOS users google group https://groups.google.com/forum/#!topic/jpos-users/X3r_PX7lgd4
but you can still carry out the encryption and decryption using some other Module instead of the JCESecurityModule (if the problem still persist). e.g. using the SunJCE

Generate cloud endpoint client library update libraries

On eclipse (appengine -> android) , how can i update the libraries that are generated by the command
'Generate cloud endpoint client library', so that it will then always generate the updated version ?
I mean google-api-client-1.18.0.jar to google-api-client-1.20.0.jar for example.
Where do they come from?
Thanks!
Your endpoint libraries are updated automatically each time you generate them from the backend project. If you don't see a class or a method, most probably it is due to one of the following:
1. a method is marked static and public. Make it private and manually add the #Apimethod annotation.
2. Also, sometimes the name of the endpoint library is different from the original class name in the backend project. Pay attention to the name attribute of the #Api annotation on the class name.
You may find these links useful:
https://cloud.google.com/appengine/docs/java/endpoints/annotations#api_api-scoped_annotations
https://cloud.google.com/developers/articles/google-cloud-endpoints-for-android/
Hope this resolves ur issue

Android Studio cloud end point newly anotated method not showing up

I m new to google cloud endpoint.I m using android studio-0.8.14. I made a new GCM End Point module with the default template.Then I added annotations for find method (which is by default NOT annotated)
#ApiMethod(name = "findDevice")
private RegistrationRecord findRecord(#Named("regId") String regId)
{
return ofy().load().type(RegistrationRecord.class).filter("regId", regId).first().now();
}
After rerunning this module,I dont get the new api for find in my api explorer.I tried rebuilding the project but no luck.I think I need to regenerate the end point library for client. Eclipse had such option but android studio doesnt have that.What if I make a entity model class and then add end point class for that all by myself, without using studio template code, will it show up in explorer?
At last I got it to work BUT after updating the android studio and using their NEW TEMPLATE for endpoint module. The module I created was created before the android studio update beta-0.8.14.That means there must be a bug. Normally a public endpoint method should be exposed to api explorer even if u dont annotate.But in my case it didnt with or without annotation. I did everything ,rebuilding the project, restarting the module backend etc but still no luck. Then I created another project and build anther module with A NEW module-building wizard, I found that the whole project structure changed A LOT...A LOT. Then I added a module (with and without annotation) which just showed up in the API explorer after restarting the backend module. Hence I think the problem must have been in the earlier module template code or somewhere else.

Share WiFi-Settings as QR-Code for WPA2 Enterprise

I have found several sources describing a String Format used to describe WiFi-Access Settings in the form of:
WIFI:T:WPA;S:mynetwork;P:mypass;;
(example taken from zxing documentation)
For basic WPA-Connections, this works just fine on my Android Device using the Zxing-Barcode-Scanner-App. However, I have been unable to find a way to embed WPA2/EAP-Connection Settings (Also referred to as WPA2 Enterprise) into a scannable 2D-Code. As I expected, inserting "L" (Login), "N" (Name) or "I" (Identification) Parameters at random positions did not really bring any advance.
Has anyone here succeeded in "embedding" WiFi-Connection Settings into a 2D-Scannable Code to work with an Android device?
Thanks for your help!
I found some information on how to format the WiFi config string in the following pull request at the github page of the zxing library project: https://github.com/zxing/zxing/pull/865
The first post contains a template of the string format, including an error (the prefix AI: is wrong, it must read A:, see here). The correct format according to the source is thus:
WIFI:T:WPA2-EAP;S:[network SSID];H:[hidden?];E:[EAP method];PH2:[Phase 2 method];A:[anonymous identity];I:[username];P:[password];;
When I tried this (using the command line tool qrencode) my Barcode Scanner app crashed. After some trial and error I figured that the option for hiding the SSID can be left out:
WIFI:T:WPA2-EAP;S:[network SSID];E:[EAP method];PH2:[Phase 2 method];A:[anonymous identity];I:[username];P:[password];;
With this I'm getting a working entry in the list of known wireless networks in Android 8.
As of now there is no support for declaring a certificate and the respective domain. If this is needed, one can specify it later by adjusting the settings from inside Android's WiFi menu.

How to retrieve brand and model info by code on Android?

There is an class android.os.Build that got static variables cointaining device info,
but when i try to access it I allways get a runtime exception.
E.x on how I try to access it:
String model = Build.MODEL;
I always get an Exception like this:
04-14 14:57:45.266: ERROR/AndroidRuntime(770): java.lang.VerifyError: com.mypackage.Main
I cant find any info about needing any special security permission on this.
Anyone got a clue?
Build.MODEL has been there since the beginning. You should not get a VerifyError from accessing that public static data member. There are a couple of ones on Build that are newer (e.g., CPU_ABI) and therefore will give you a VerifyError if you are trying to access them on older devices/emulators -- the documentation indicates in which API levels the various data members were introduced.

Categories

Resources