Create() method called multiple times - libgdx

Create() method of my game class is being called in onSurfaceChanged(GL10,int,int) and onSurfaceCreated(GL10,EGLConfig).
So whenever the game is interrupted by any thing i.e call,sleep , it restarts .
I cant find any thing ..plz help .How do i stop this.

If this is happening on Andorid, if you rotate your device form profile to landscape mode and vice versa try this:
Try fixing your orientation in the manifest file and specify that you
will handle orientation changes yourself:
<activity android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|orientation" ...>
If create() is called if you return after pause(), it is probably, because your app was closed by the dalvik VM. Try it on different devices. If the issue stays the same update your question here with relevant test and results. If we can't help you try to write a new issue on their page or ask in the forum.

Related

DataVizExtention: issue with clearing viewables while a sprite is selected

In my code, I have this workflow:
When user wants to see some things, add Sprites using 'DataVizCore.addViewables()'
Use 'viewer.addEventListener(DataVizCore.MOUSE_CLICK, onDotClick)' to show info bubble
When user wants to show other things, call 'DataVizCore.removeAllViewables()' to clear Sprites
Repeat from step 1
This sequence works OK except in one situation.
If a sprite was selected (by clicking on it) before removeAllViewables() is called, I don't get MOUSE_CLICK event for newly added Sprites. In browser console, I see following error is thrown.
CustomViewables.js:318 Uncaught TypeError: Cannot read property 'style' of undefined at ViewableData.getViewableUV (developer.api.autodesk.com/modelderivative/v2/viewers/7.*/extensions/DataVisualization/DataVisualization.js:454)
As a workaround, I added 'event.hasStopped = true' to click event handler to prevent Sprite getting selected internally. That seems to work.
This seems like a bug in DataVizExtension to me. Or, my workflow is wrong?
Thanks
Bandu
Bandu. Thanks for the detailed steps to reproduce this issue. I tried with v7.46.0 version of the DataVisualization.js (latest as of my message) but was not seeing the same issue. I'd be curious if you are using this same version of the Forge Viewer (you can figure that out by looking at the viewer3D.js fetched under the Network tab of Chrome DevTools).
Setting event.hasStopped = true works because it internally avoided the code path calls into getViewableUV that threw the exception, but the flag is meant for other use cases (e.g. overriding default sprite selection behavior).
In any case, I've just tweaked our internal code to make use-cases like yours more robust. The changes will be released with the upcoming v7.47.0. Thank you for your feedback 🙂

DisplayRootView Crashing with an AV (v2.0.0.0 stable) on WP81 WinRT Stack

The program '[3188] Sprudelsuche.WP.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
This is the last line in Output, before that I get
'Sprudelsuche.WP.exe' (CoreCLR: .): Loaded 'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was built without symbols.
[Caliburn.Micro.View] ERROR: System.NullReferenceException: Object reference not set to an instance of an object.
at Caliburn.Micro.View.SetContentPropertyCore(Object targetLocation, Object view)
Effect is that app shows splash briefly, then closes immediately.
The application in question is on GitHub at https://github.com/christophwille/Sprudelsuche/blob/master/Source/Sprudelsuche.WP/App.xaml.cs - the reason I started trying DisplayRootView is that DisplayRootViewFor doesn't work with navigation later in the app (MainViewModel/NavigateTo: Output shows it is activating the new view model, but the view never comes up).
I use CM in a WP8 SL app with no issues whatsover. However, this has me stumped as I didn't deviate much from the CM samples in this very simple port. (btw, NavigateToViewModel exhibits the same issue)
Bootnote: I noticed a interesting tidbit in the source code for DisplayRootView - handling of the frame after navigation compared to DisplayRootViewFor. Also, in the Hub the convention based binding didn't work for me. I sure am doing something wrong...
look at your line of code in PrepareViewFirst(Frame rootFrame)
you have
protected override void PrepareViewFirst(Frame rootFrame)
{
container.RegisterNavigationService(this.RootFrame);
}
it probably should be
protected override void PrepareViewFirst(Frame rootFrame)
{
container.RegisterNaviationService(rootFrame);
}
then
DisplayRootView<MainView>();
should work just fine;
edit:
try moving PrepareViewFirst() method to the bottom of the Configure override. There are 2 PrepareViewFirst() methods one parameterized and the other not... use the un-param'd method in Configure(), comment out the call in OnLaunched();
In writing comments to mvermef's answer I started trying out copying code to a blank project / using a different view for startup. As this worked a-ok, my remark "binding doesn't work" reminded me that I tried a hell lot of different approaches to make it work, and lo and behold, one of those had remained in the source code:
<Hub Header="spritpreise">
<HubSection Header="SUCHE">
<DataTemplate>
<Grid caliburn:View.Model="{Binding}">
The AV crash was caused by the last line. Turning it back into a Grid without the CM-VM-binding made the app work. Funny though that this only crashes View-first, and not ViewModel-first.

Page constructor called multiple times - Windows Phone 8

I have a page in a WP8 application, that every time I navigate to it, the constructor is called.
From what I know, the constructor of a page called only once at the first time the page loaded. my page is very heavy, and every construction takes wasted time..
this my navigation code, usual one:
NavigationService.Navigate(new Uri("/Views/Pages/ContentControlNew.xaml", UriKind.Relative));
and this is the constructor of the page:
public ContentControlNew()
{
InitializeComponent();
}
Not special.. is it normal that the constructor is called every time? Please tell me if you need more details because I don't know what else to say about this subject.
Yes this is normal because whenever you use NavigationService.Navigate it always creates a new page object and adds that (pushes it) to the navigation stack. For example when you use GoBack() it pops it out of the stack and destroys it, but when it gets back to the previous page it doesn't call the constructor since that one was already in the stack and does not have to be recreated.
If you don't want to create a page every time you navigate to it, you should look into Navigation Models for Windows Phone for some ideas on how you can tackle this.

Share Target and JumpListItemBackgroundConverter

I've added the Share Target declaration to my app for the data format WebLink and everything works as expected. However, when I add a JumpListItemBackgroundConverter or JumpListItemForegroundConverter anywhere in the app, the app hangs on the splash screen when you enter the app using the Share from IE. No exception, no crash, the debugger doesn't even stop. All I get is a cryptic error in the output window, "The program '...' has exited with code -1073741819 (0xc0000005) 'Access violation'." The documentation for those converters say they're fine with universal apps, just that they've been moved to a different namespace. Has anyone been able to get these two things to work in the same app? If so, where did I go wrong? Or is there something better than those two converters to get the LongListSelector look and feel?
Steps to reproduce:
Create a new universal app. I chose hub.
Add a share target of format WebLink to the appxmanifest declarations.
Add a new page to point the share contract to.
Add the OnShareTargetActivated code to app.xaml.cs to open the new page. See code below
Add a JumpListItemBackgroundConverter to the resources of the main page of the app. You don't need to apply it to anything, just declaring it is enough to break the sharing.
Go to IE and share a link. It should hang on the splash screen.
Code for app.xaml.cs:
protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
{
// Replace SharePage with the name of the share target page
var rootFrame = new Frame();
rootFrame.Navigate(typeof(SharePage), args.ShareOperation);
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
It turns out this is a bug in the emulator. It works if you test on a physical device.
MSDN Forum - JumpListItemBackgroundConverter and Share Target in Windows Phone 8.1

Why is the motion event not triggered?

I have a problem while trying to get the accelerometer data using the HTML 5 interface.
I declare this handler event:
window.addEventListener("devicemotion",getMontionData,true);
to get the data provided by the accelerometer sensor. On the other hand, I have a function called as getMontionData:
getMontionData = function (e)
{
xAcceleration = e.acceleration.x;
yAcceleration = e.acceleration.y;
zAcceleration = e.acceleration.z;
}
to get the accelerometer data. The problem that I have is that the getMontionData function is not called when the device is locked or the screen is on black.
I'm doing this test on a smart watch using Tizen IDE and it is set this property
Could anybody explain me how to enable the application to get data even though the device is locked or the screen is on black?
While the application main window is displayed, the devicemotion event should be called since the getMontionData function is called. The problem happens, when the device screen is on black
Thank you so much
Try adding this line to test if event gets triggered, if it does - find out why it's not being fired.
$(document).trigger('devicemotion');
Try adding the following setting to your config.xml as described in the documentation:
<tizen:setting background-support="enable" />
Without this the application can't run in the background, so the event doesn't work.