Unfortunately, this is a binding bug. :-(

        https://bugzilla.novell.com/show_bug.cgi?id=660400

The workaround is to use JNIEnv to invoke the member (untested):

        IntPtr enableForegroundDispatch = JNIEnv.GetMethodID(
                        mNfcAdapter.Class.Handle,
                        "enableForegroundDispatch",
                        
"Landroid/app/Activity;Landroid/app/PendingIntent;[Landroid/content/IntentFilter;[[Ljava/lang/String;)V");
                        // [0]
        JNIEnv.CallVoidMethod(
                        mNfcAdapter.Handle,
                        enableForegroundDispatch,
                        new JValue (this), new JValue (mPendingIntent), new 
JValue (null), new JValue (null));

I'm sorry for the inconvenience.

 - Jon

[0] Method signature obtained from:

$ javap -s -classpath /opt/android/sdk/platforms/android-10/android.jar 
android.nfc.NfcAdapter

Update paths as appropriate; the relevant output is:

public void enableForegroundDispatch(android.app.Activity, 
android.app.PendingIntent, android.content.IntentFilter[], 
java.lang.String[][]);
  Signature: 
(Landroid/app/Activity;Landroid/app/PendingIntent;[Landroid/content/IntentFilter;[[Ljava/lang/String;)V

The Signature value can be copy-and-pasted into the signature parameter in 
JNIEnv.GetMethodID().

On Oct 9, 2011, at 9:08 PM, Ram Venkatesh wrote:

> Hello,
>  
> <self-confessed newbie to Mono for Android, so this could well be pilot error>
>  
> I am trying to use the Nfc APIs in Android API version 10 from Mono for 
> Android v 1.9.1.r2-2.
>  
> The code in my activity looks like this:
>  
>         protected override void OnResume()
>         {
>             mNfcAdapter.EnableForegroundDispatch(this, mPendingIntent, null, 
> null);
>         }
>  
> The exception thrown is:
>  
> Java.Lang.NoSuchMethodError: Exception of type 'Java.Lang.NoSuchMethodError' 
> was thrown.
> at Android.Runtime.JNIEnv.GetMethodID (intptr,string,string) [0x00024] in 
> /home/jpobst/Desktop/monodroid/Mono.Android/src/Runtime/JNIEnv.cs:359
> at Android.Nfc.NfcAdapter.EnableForegroundDispatch 
> (Android.App.Activity,Android.App.PendingIntent,Android.Content.IntentFilter[],string[])
>  [0x00014] in 
> /home/jpobst/Desktop/monodroid/Mono.Android/platforms/android-10/src/generated/Android.Nfc.NfcAdapter.cs:83
> at MyFirstApp.Activity1.OnResume () [0x00001] in 
> C:\svn\s3edge\Proto\Venkar\LearnAndroid\MyFirstApp\Activity1.cs:58
> at Android.App.Activity.n_OnResume (intptr,intptr) [0x00008] in 
> /home/jpobst/Desktop/monodroid/Mono.Android/platforms/android-10/src/generated/Android.App.Activity.cs:2411
> at (wrapper dynamic-method) object.cf9d5023-0ae1-4d9f-88ba-4f49448e4156 
> (intptr,intptr) <IL 0x0000c, 0x0002b>
>  
>   --- End of managed exception stack trace ---
> java.lang.NoSuchMethodError: enableForegroundDispatch
>                 at myfirstapp.Activity1.n_onResume(Native Method)
>                 at myfirstapp.Activity1.onResume(Activity1.java:35)
>                 at 
> android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
>                 at android.app.Activity.performResume(Activity.java:3832)
>                 at 
> android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
>                 at 
> android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
>                 at 
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
>                 at 
> android.app.ActivityThread.access$1500(ActivityThread.java:117)
>                 at 
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
>                 at android.os.Handler.dispatchMessage(Handler.java:99)
>                 at android.os.Looper.loop(Looper.java:130)
>                 at android.app.ActivityThread.main(ActivityThread.java:3683)
>                 at java.lang.reflect.Method.invokeNative(Native Method)
>                 at java.lang.reflect.Method.invoke(Method.java:507)
>                 at 
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
>                 at 
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
>                 at dalvik.system.NativeStart.main(Native Method)
> }              Java.Lang.NoSuchMethodError
>  
> Can someone shed some light on the error and any potential workarounds?
>  
> Thanks!
> Venkatesh
> _______________________________________________
> Monodroid mailing list
> [email protected]
> 
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to