Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / AGK For Pascal - Android Problems

Author
Message
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 11th Dec 2012 16:15
Hi All and thanks for any help in advance....

I have tried to compile my app to android and the process is working however there are some things I don't get:

1) My game reads a text data file for level data. This works fine when run on windows but it seems that the file cannot be read on the android device? Where should the text file go in the directory structure...currently its in Assets\media?

2) When run from Eclipse it starts on my Nexus 7 (albeit with missing graphics which I assume is because of the file issues mentioned above}....thats great however, when I stop the app and run it from the Nexus i just get a blank screen?? any ideas?

Thanks

Constantly seeking!
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 11th Dec 2012 16:38
I'd have to check - but files just in assets should work.

However, AppGameKit does unspeakable things with directory paths when it starts up. Have you modified the postbuild.bat file to copy the stuff at the end of the compile in Delphi or FP?

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 11th Dec 2012 16:47
Jim

Thanks for a speedy come back

Using FP (Lazarus)...It seems that if I examine the app on the nexus under settings-?devices->apps and select clear data...It works (without the text file scenery graphics). Why is this deletion required? I cannot expect joe blogs to do this every time??

Very Strange

Constantly seeking!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 11th Dec 2012 17:03
The Daddy, a possible issue is the name of the file and how you are using in the code. Android is case sensitive, so the name of the file and how you reference it need to be exactly the same.

If you put your file in a sub directory under media, then you need to make sure that the cases are all the same in the actual directory and how you reference it in your code.

If you are doing Tier 1, you need the media directory under the assets directory in your Android project.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 11th Dec 2012 19:48
ok...so it seems that only files that have a .txt extension can be read.....so my level map file 'levfile.lev' will not work....okay so thats one problem solved....

How do I solve the issue with the app writing data....once run it will not run again until I go on my nexus 7 and delete the apps data? I cannot expect a user to do this so how do I over come this?

Thanks once again!

Constantly seeking!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 11th Dec 2012 20:33
Quote: "so it seems that only files that have a .txt extension can be read"

That's not quite correct. I thought the same thing at first, when I changed my level files to .bin extensions.

But I know the kind of problems you are having. I had to uninstall my app and delete the resources.ap_ and the .apk file in bin BEFORE I did a clean and build to get my app to recognize the .bin files the first time.

I haven't tried updating them recently to see if the new ones 'take'.

And I don't know if this is an AppGameKit or an Android issue.

I'm trying to handle an issue for a paying customer right now (web stuff), so I can't test other bits for a while.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 11th Dec 2012 20:35
Darn those paying customers!

The data issue is confusing me!

Constantly seeking!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 11th Dec 2012 21:31
Paying customers all done! (Now, we hope they actually pay the bill promptly, it depends on when their customer pays their bill.)

I'm going to try some tests on my two Android devices. One is an up to date Nexus 7 and the other is a Toshiba 7" Thrive, Android 3.2.1.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 11th Dec 2012 21:47
I just added a new pair of .bin files and updated an old one. Then I rebuilt in cygwin, refreshed and ran in Eclipse, copied the apk to my local download site, downloaded and installed on both my Androids.

And the new data and update were visible.

So, all my data file issues seem to have disappeared. I suspect it was a permissions issue for my initial problems.

I don't know why you would be having a problem. Maybe it is something about how the apk is built, since I suspect it is different for Tier 3.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 11th Dec 2012 22:46
This might be an Eclipse/Android problem. I've had some occasions where only switching the Andoid off, deleting files in the file manager, and then sending new stuff works.

Erik is the expert on the nuts and bolts! Having said that, Android is probably the area where the clouds of unknowing loom darker for all of us.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 12th Dec 2012 09:46
Thanks guys. Not being experienced on the Android side I am not sure

A) why my app creates data on the android device

And

B) Why this stops it running a seond or third time?

Could it be to do with the app not actually stopping when I press the button on the Base of the Nexus? Does this just switch to the home screens but leaves my spin memory or running in the background. Then of course will not start again as it is already running?

I have no clue!

Constantly seeking!
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 12th Dec 2012 10:36
Your app will copy files to writeable space.

Android apps don't really close, they go into a sleep state. That's why I recommend powering the phone/tablet down before trying a new version of your app, or killing it in the task manager:

http://www.ehow.com/how_5808183_close-apps-android.html

A bit more research says it's actually quite hard to really kill an app programatically on Android versions <4.4. Obviously, compiling new versions requires that we get the app out of memory before replacing the executable.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 12th Dec 2012 10:38
Ok so when, on my android dev (nexus 7) under developer options I select

'don't keep activities'
Destroy every activity as soon as the user leaves it


The app works everytime I choose it. When this is not selected, once run it will not run again until I physically delete the app data.

So I assume it is something to do with the app not actually ending when the 'home' key is pressed. So I guess I need a way programatically of detecting this key press and ensuring the app is stopped...not run in the back ground.

Any ideas how I would achieve this in tier 2 (pascal - lazarus)???????

Constantly seeking!
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 12th Dec 2012 10:41
See above!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 12th Dec 2012 12:40
Jim

Thanks. I am doing that...forcing the app to stop.

However my problem is that when I compile the sprite test program (AGK for pas) for android, run from eclipse as sure as hell it appears correctly on my nexus. S then I press the home key and of course return to the home screen. Wen I 'click' on the sprite test app it runs again as it should!

When I do the same with my app, run from eclipse it works on the nexus. However after pressing the home key and running it again I just get a blank screen? As soon as I force stop or delete the app data it works fine again. I of course do not want this to happen but don't know what to do to avoid it? I can only assume the my app 'resumes' where it left off but no graphics are loaded? If I do not force stop or delete data no matter how many times I run my app I get a blank screen?....arrrrggghhhh what can I do or what am I doing wrong?

Wy does this happen with my app and not the example android app?

Constantly seeking!
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 12th Dec 2012 13:22
It's a pain the arse! All this just so that things start up a bit faster.

Looks like a lot depends upon what you do in the shut-down section. Which example are you using?

Very few of the examples actually have an explicit "exit" button. Have you implemented one? If so, it's probably calling the shutdown method, which will almost certainly delete the images etc.

You could try putting Halt(0) at the very end of the shutdown, but it's regarded as bad practice on Android.

If you want to zip up the project and send it to me I'll happily take a look - in strict NDA and confidentiality - because it may be that we need Erik to add some Android-specific stuff to the templates. jim atsign melissi.co.uk

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 12th Dec 2012 13:32
Jim


You are a star of stars a gent amongst men......will zip and send.

Constantly seeking!
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 12th Dec 2012 13:40
I should also have said that all this has implications not just for Pascal but across the board. I'd be interested to know what the "End" command is actually doing in Tier 1. I'm really glad you raised this issue.

Ideally, the OS would send a "resumed" message, and then we could call appropriate action to reload the scene data.

I'll have a look at the AppGameKit for Pascal source and try to determine exactly what's happening. It may be that on Android we should never force a quit. Frankly, I think the Android OS is a pile of donkey manure in many respects, not least the fragmentation across different hardware and the way subtle differences on later versions break older code.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 13th Dec 2012 08:22
Somehow this has been slipped past me... using Pascal AppGameKit it is possible to build Android app? Any problems comparing to normal Tier 1 style?

That end/resume/running background thing is quite odd as 99% android apps allow you to quit (finish activity) and I have not seen any problems with that. Really there should be "standard" pause/resume/end handlers in AGK.. It is not ok to AppGameKit app use lot of processor power while in background and that developers should not need to "hack" AppGameKit core to get around that (sleep xxxx ms) Proper pause/resume/end available for developer.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 13th Dec 2012 11:57
Jogimus - yes it is possible to program Android.

Quote: "99% android apps allow you to quit"


This is simply NOT true. It is against the style-guides for Android to have a Quit button, and mostly doesn't work anyway. See a lengthy discussion of this here:

http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon

When the user presses the Home or Back button the process effectively sleeps. It doesn't exit. It will be killed when the machine gets low on memory. If the user re-starts it, it will Resume, it won't actually restart. This has a number of implications for AppGameKit programs - for example has the Gl surface been lost.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 13th Dec 2012 12:52
Almost all apps allow user to quit, whatever it is by BACK button or actual menu item or button inside an app. To me or end user it does not matter if system _really_ kills the app or just pauses it, main thing is that allows user to sense of quiting app and when user starts the app again it "looks like" it starts from scratch or resumes where it was. And big thing is that even if the app is still in background it does not bother user anymore (zero processor load, and not showing in task list)

I usually uninstall any program that does not behave correctly: Home button -> app pauses and goes to background, Back button -> exit directly or by some kind of exit menu.
If app does not respond to back button and I have to exit with Home button -> app appears as active application in Task manager, I consider it as bad app. Fortunately there is not many these kind of apps
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 13th Dec 2012 13:10
I think you should read up on the Android SDK!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 13th Dec 2012 13:44 Edited at: 13th Dec 2012 13:51
From android documentation, Back button:
Quote: "Activity Stack

As the user moves from activity to activity, across applications, the Android system keeps a linear navigation history of activities the user has visited. This is the activity stack, also known as the back stack. In general, when a user starts a new activity, it is added to the activity stack, so that pressing Back displays the previous activity on the stack. However, the user cannot use the Back button to go back further than the last visit to Home.
"


and internal use of back button:

Quote: " But what if your application is one big activity with several pages of content and needs finer-grained control of the Back button? Examples of such Google applications are the Browser, which can have several web pages open at once, and Maps, which can have several layers of geographic data to switch between. Both of these applications take control of the Back button and maintain their own internal back stacks that operate only when these applications have focus.
...
If the user keeps pressing back, they will eventually leave the browser activity and return Home.
"


Quiting from app using Back key is normal, and it is okay to handle Back key from your app if it needs more control that regular "activity stack back".

Again, almost all apps behave like this, user can quit from app!

edit:

and more:
Quote: "Shutting Down an Activity

You can shut down an activity by calling its finish() method. You can also shut down a separate activity that you previously started by calling finishActivity()."
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 13th Dec 2012 14:14
See the docs. Finish() doesn't!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Jogimus
11
Years of Service
User Offline
Joined: 10th Nov 2012
Location:
Posted: 13th Dec 2012 15:24
Quote: "

public void finish ()
Added in API level 1

Call this when your activity is done and should be closed. The ActivityResult is propagated back to whoever launched you via onActivityResult().
"


I assume it works fine as there is no problem with most of android apps. Again, from user point of view, I does not matter what happens behind curtains if for user an app acts like it is ended (consumes no processor, and does not appear in active application list)

For question number 2 in first post, Home key does not even try to quit/end an app, so if it does not resume like it should by selecting app from Active application list/task manager or clicking it's icon, there is clearly pause/resume problem... I was under impression that AppGameKit can handle that internally.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 13th Dec 2012 15:55
Sure - I'm trying to establish whether this is an AppGameKit problem, a Pascal implementation problem, or an application coding problem.

The Daddy has sent me his entire project, and I'm working on it!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 13th Dec 2012 16:57
Quick report:

It isn't only The Daddy's project that exhibits poor behaviour on resume (unresponsive black screen) when restoring. I suspect that the main loop is halting or pausing and not rendering. This may be a Pascal implementation problem.

The good thing is that I can reproduce it - always a happier place to be!

Tomorrow I'm going to add some native (non AGK) Pascal debugging code to a simple unit, so that we can all get at least a log file when various things happen. So bear with me for a couple of days - I have other things to do!

This is not to do with using Eclipse to transfer and run, because I don't. I put the APK on a pen drive, so there's no interference and it's more like a user installing an app.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 14th Dec 2012 21:56
Look forward to your findings Jim!

I would not be surprised if this issue is the fault of any of them...AGK, pascal or android....I would be surprised if its pascal to be honest....but both AppGameKit and Android are....works in development....I think that puts it politely!

If you want me to do anything let me know Jim!

Constantly seeking!
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 14th Dec 2012 23:35 Edited at: 14th Dec 2012 23:35
The Daddy - slow progress today, largely as a result of an impromptu company Christmas lunch in a local wine bar, which involved a few bottles of vino.

The real pork chop in the vegetarian shopping basket is the Home key on Android. I'm fairly happy with the Back key (=Escape) meaning Get Me Out of Here, even if that means the Andoid OS doesn't actually allow the quit to complete, in which case I'm old-fashioned enough to think that that's daft behaviour, but not our fault.

The Home key cannot be trapped, so the question is whether to let AppGameKit handle this or promote it up to application level when the app is put into a Pause state.

To be fair, quite a lot of Windows' behaviour is stupid, but we're so used to it that we just program around it and carry on.

Unfortunately, we can't redefine what the Android OS does. For example, as I type this I'm listening to some beautiful singing by a bunch of Benedictine nuns (not sure "bunch" is apt, but bless you Sisters!) and I've minimised Media Player. AFAIK you can't do this on Android. The Home key will not kill the nuns, but it will stuff a cork into their mouths until we go and find them again.

So we need: the best axe we can get to chop the app when the Back key is pressed (or a Quit button clicked). We also need to ensure that Suspend and Resume with the Home button work according to the official route.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 15th Dec 2012 23:09
Small update. This looks like a Scene suspend problem that only appears on Android.

I have passed this up to Erik for attention, because I don't want to mess with the elegant code. The Scene concept is the most beautiful thing I've seen since my first glimpse of my first girlfriend's knickers, so I really want it to work 100%.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 17th Dec 2012 08:09
JimHawkins:
Quote: "The Scene concept is the most beautiful thing I've seen since my first glimpse of my first girlfriend's knickers, so I really want it to work 100%."


+1
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Dec 2012 11:24
I no longer think this is a Pascal problem.

I have just tried the 3D test APK that Paul posted. Pressing the home button and then going back to the app has made the display go black and the tablet is now so locked-up that it won't even switch off with the power button!

This is Android 4.0 (I think!)

Would be helpful if others could try this on different hardware.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Dec 2012 11:57
Interestingly enough - the 3D demo exited after 30 minutes!!

There has to be a problem with the sleep-resume routines in AGK. Should I formally report this?

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Neslib
11
Years of Service
User Offline
Joined: 8th May 2012
Location: San Diego, CA, USA
Posted: 24th Dec 2012 16:16
The Android resume issue is my bad. I'm sorry about that. Let's say it is my inexperience with the Android OS

Fortunately, the solution is very simple: just delete some lines of code in AGKPlatform_Android.pas. Look for the implementation of the TAgkPlatformAndroid.TermDisplay method and delete this block of code:

if (not FTerminated) then
begin
FTerminated := True;
App := TAgkApp(TAgkApp.Instance);
App.ShutDown;
end;

This code caused to app to prematurely shut down when it went to the background. I don't know why I put that in there

Anyway, I will incorporate the fix into the next (108x) version.

Happy Holidays!
(For some strange reason, saying Merry Christmas is not PC in the US )
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 24th Dec 2012 17:51
Excellent news!

Both Big Daddy and I can confirm that it works!

Vrolijke Kerstmis en gelukkige nieuwjaar

Is it okay to say it in Dutch???

Jim

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL

Login to post a reply

Server time is: 2024-05-03 21:20:30
Your offset time is: 2024-05-03 21:20:30