Skip to content

Instantly share code, notes, and snippets.

@abolibibelot
Created March 20, 2011 22:24
Show Gist options
  • Save abolibibelot/878737 to your computer and use it in GitHub Desktop.
Save abolibibelot/878737 to your computer and use it in GitHub Desktop.
Scary interop in monodroid to make mapviews kinda work
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace GoogleMaps
{
[Activity(Label = "Managed Maps", MainLauncher = true)]
public class Activity1 : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
var button = FindViewById<Button> (Resource.Id.MyButton);
var mapActivity = Java.Lang.Class.ForName("mono.samples.googlemaps.MyMapActivity");
var list = new JavaList<Java.Lang.Object>()
{
48.8668906d,
2.3975663d,
"Please kill me now"
};
SetList(list);
button.Click += delegate { StartActivity (new Intent (this, mapActivity));};
}
private void SetList(JavaList<Java.Lang.Object> list)
{
IntPtr receiver = JNIEnv.FindClass("mono/samples/googlemaps/MapReceiver");
IntPtr setter = JNIEnv.GetStaticMethodID(receiver, "setCoordinates", "(Ljava/util/List;)V"); //TODO: signature
JNIEnv.CallStaticVoidMethod(receiver,setter,new[]{new JValue(list)});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment