Start a new topic

Xamarin PCL or Shared project

Xamarin PCL or Shared project

1 person has this problem

I did this, but get a blank white screen that says Wikitude SDK on top. The camera doesn't start.

Any ideas?

[assembly: Xamarin.Forms.Dependency(typeof(AugmentedRealityImplementation))]
namespace UXDivers.Artina.Grial
{
    public class AugmentedRealityImplementation : IAugmentedReality
    {
        public AugmentedRealityImplementation() { }

        public void LaunchWikitude()
        {
        
        var storyboard = UIStoryboard.FromName("MainStoryboard_iPhone", null);
        var controller = (UIViewController)storyboard.InstantiateViewController("StoryBoardViewController");

        var window = UIApplication.SharedApplication.KeyWindow;
        window.RootViewController = controller;

        }
    }
}

 

I've also integrated the WikitudeSampleAndroid project files into the Android PCL native side and it compiles, but does not run properly and crashes. I need guidance here too. 


Just a note, I am creating a GEO AR experience around the stage at an upcoming festival with Wikitude. My client will purchase your SDK as soon as show them an integrated sample into their App. We are in a time crunch as this is for a 'High Profile Public Event' in downtown Miami in 3 weeks from now. Your support is much appreciated. 

Got it working with:

        public void LaunchWikitude()
        {

        var storyboard = UIStoryboard.FromName("MainStoryboard_iPhone", null);
        var controller = storyboard.InstantiateViewController("StoryBoardViewController") as UIViewController;

        var window = UIApplication.SharedApplication.KeyWindow;
        window.RootViewController = controller;
        window.MakeKeyAndVisible();

        }

 

Had to delete and re-import everything and make sure all classes where properly associated. 


I hereby bestow the highest of commendations upon you for solving this issue yourself and kindly providing the solution you have found as well. We really appreciate it.


Thanks and kind regards

Daniel


1 person likes this

Hi Daniel, surprise it's 2am and I'm still up programming. Thanks for the nice comment :) I have yet to figure out the Android side too. Haven't got past that one yet. 


We are in such time crunch to launch the App for the festival, and I really want to get the AR in there and WOW the crowds! Cross my fingers working hard on this!!

Hi Guys,

I integrated the GEO sample into my PCL Android Xamarin App. 

Using dependency injection I am firing up the sample with following code. 

class AugmentedRealityImplementation : Java.Lang.Object, IAugmentedReality
    {
        public AugmentedRealityImplementation() { }

        public void LaunchWikitude()
        {
            var intent = new Intent(Android.App.Application.Context, typeof(WikitudeActivity));
            intent.SetFlags(ActivityFlags.NewTask);
            Android.App.Application.Context.StartActivity(intent);
        }

    }

 It crashes at the very of the Wikitude Activity OnCreate method with no error messages. It just breaks.

protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView(Resource.Layout.sample_cam);

			Title = TITLE;

			architectView = FindViewById<ArchitectView>(Resource.Id.architectView);
			ArchitectStartupConfiguration startupConfiguration = new ArchitectStartupConfiguration();
			startupConfiguration.setLicenseKey(WikitudeConstants.WIKITUDE_SDK_KEY);
			startupConfiguration.setFeatures(ArchitectStartupConfiguration.Features.Tracking2D);
			startupConfiguration.setCameraResolution(CameraSettings.CameraResolution.Auto);

			/* use  
			   int requiredFeatures = StartupConfiguration.Features.Tracking2D | StartupConfiguration.Features.Geo;
			   if you need both 2d Tracking and Geo
			*/
			int requiredFeatures = ArchitectStartupConfiguration.Features.Tracking2D;
			MissingDeviceFeatures missingDeviceFeatures = ArchitectView.isDeviceSupported(this, requiredFeatures);
			

			if ((ArchitectView.getSupportedFeaturesForDevice (Android.App.Application.Context) & requiredFeatures) == requiredFeatures) {
				architectView.OnCreate (startupConfiguration);
				architectView.RegisterUrlListener(this);
			} else {
				architectView = null;
				Toast.MakeText (this, missingDeviceFeatures.getMissingFeatureMessage(), ToastLength.Long).Show();

				StartActivity (typeof(ErrorActivity));
			}	
		}

Any ideas?

I cleaned the project, rebuilt and it's running. My inject code is good. We did it!

Thank you yet again for being so diligent and figuring this out yourself before I even had the time to have a look at it.


If I were allowed to have a favourite customer you would be it. Good luck with the upcoming event.


Kind regards

Daniel


Wikitude likes all its customers indiscriminately and discourages all kinds of favouritism.


1 person likes this

Thanks for the gracious response Daniel. Got both Android and iOS versions properly integrated and firing up in the PCL Xamarin! Starting to do the creative fun part now! 3D modeling and animations for the main stage!!!

Warm regards,

Alex

Hi guys,

How do I exit out of the AR mode (camera mode) and go back to my PCL interface? I'm thinking of putting a button on the bottom of the AR camera mode - but what is the javascript code to exit?

Good morning,



you will need to call the C# side by using the architectsdk:// protocol, there is no JavaScript API call for this.


in JS:

 

onButtonClicked: function()
{
    document.location = ""architectsdk://exitthearworld?param1=" + encodeURIComponent(param1);
}

 

in C# (iOS):

 

public partial class MyArchitectViewDelegate : WTArchitectViewDelegate 
{
	public override void InvokedURL(WTArchitectView architectView, NSUrl url)
	{
		// parse the url received and act based on it
	}
}

public partial class MyExampleViewController : UIViewController
{
	private MyArchitectViewDelegate architectViewDelegate = new MyArchitectViewDelegate ();

	public override void ViewDidLoad ()
	{
		this.architectView.Delegate = architectViewDelegate;
	}
}

 

iOS docs

Android docs


The Xamarin component samples include most of this code, but don't actually do anything with it other than printing the invoked url.



Kind regards

Daniel

Thanks Daniel. Got that working up to a certain point. Having trouble with this..


Here in this code, how to make a call to StopAR() and return back to my PCL interface. 

public override void InvokedURL(WTArchitectView architectView, NSUrl url)
	{
		// parse the url received and act based on it
	}

 

Hi Alexandre,



I really don't know much about C# or Xamarin application development, but my thinking was along those lines:


  

public partial class YourArchitectViewDelegate : WTArchitectViewDelegate 
{
	UIViewController _current;
	UIViewController _next;

	public ExampleArchitectViewDelegate(UIViewController current, UIViewController next) : base ()
	{
		_current = current;
		_next = next;
	}

	public override void InvokedURL(WTArchitectView architectView, NSUrl url)
	{
		// some URL parsing code

		if (*/ result of URL parsing code */)
		{
			architectView.Stop();
			_current.PresentViewController(_next, true, null);
		}
	}
}

  

 

public YourExampleViewController (IntPtr handle) : base (handle)
{
	architectViewDelegate = new ExampleArchitectViewDelegate(this, somOtherViewControllerToSwitchTo);
}

 

Will this be feasible?



- Daniel

Login or Signup to post a comment