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 / File open handle on initialization - windows and android

Author
Message
blurymind
7
Years of Service
User Offline
Joined: 25th Jun 2017
Location:
Posted: 10th Mar 2018 20:48
I want to create an android app that opens a specific filetype, however appgame kit doesnt seem to have a way of initialising its app with cmd line arguments- at least not a built in way that works on all the supported platforms.

So My question now is- what is the best practice to do this with appgame kit? Say I want to make a simple image viewer. You open a picture file with it, just by clicking on the picture file.
How do I tell it to open the picture file that I clicked on?

How do I do it in a way that works on windows and android?
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 10th Mar 2018 22:36
Go into the samples directory (the example project files that come with AGK) and open "ChooseImage" in the Image folder.

This program literally allows the user to to choose an image then loads it and displays it in AGK. Its already written for you. Id recommend everyone familiarises themselves with the examples that come with AGK.

it works on Windows and Android.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 11th Mar 2018 02:53
@blurymind

If I've understood, you want the user to click the picture and then AppGameKit to open up and display the picture (not opening the app and then choosing it from a file selector), is that correct? If so, not sure you can. The opening of your app by clicking the picture is a file association in the OS, you would need to set that up, which I doubt you can do via AppGameKit, especially not on mobile devices. Then the app might open, but certainly wouldn't do anything with the picture.

That's not really what AppGameKit is intended for, but maybe with T2 you could do it.
blurymind
7
Years of Service
User Offline
Joined: 25th Jun 2017
Location:
Posted: 11th Mar 2018 09:46
@bengismo I dont want to make the user laboriously chose files from within the app. I want the app to open when the user clicks on the file

As far as I know that is done by giving the app some command line parameters to work with on initialization. If there is a file path, it should open the file. If there isn't it should open a "choose file dialog"

@santman yes that is exactly what I want to do. Why is appgamekit not meant to do that? It has the word "APP" in the title, doesnt it? Most apps can take command line parameters, so it strikes me as a HUGE flaw for any app development toolkit not to have this fundamental feature.

I thought that maybe it could be done with tier2, but I dont even know where to begin. AppGameKit plugins seem to be made only for windows and linux. Nothing for android
blurymind
7
Years of Service
User Offline
Joined: 25th Jun 2017
Location:
Posted: 11th Mar 2018 10:28
Just to clarify- what I am interested is file association. So whenever the user clicks on say a webm file, the operating system - be it windows or android- fires my appgamekit app and the app loads that file automatically
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 11th Mar 2018 12:32
Teir 2 is the best option for this...

In windows you can get the command line argument and set your app as the default application for the file type. Then when a user double clicks on a png...your app opens up and is passed the filename.

Android is harder but still possible:
You can set what app opens a given type of file in the android settings menu. You can change the default app for different file types and so android will start your app instead of the gallery android view for example.

To open the correct file you will have to change your manifest to recieve message intents
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />

Your app then has to respond to intent messages and then open the file that it is passed by android.


Im hoping that the command line argument is implemented in AppGameKit in the next release. It already appears to be in the lanhuage but doent seem to work. If it was implemented then teir 1 could be used (at least on windows).
blurymind
7
Years of Service
User Offline
Joined: 25th Jun 2017
Location:
Posted: 11th Mar 2018 15:21 Edited at: 11th Mar 2018 15:31
@bengismo thank you for the hint. How do we link the manifesto signals with appgamekit?
Are there any good tutorials out there to get me started on this?

I think it would be a valuable feature to have in AppGameKit and it will give it a competitive edge over other engines

I found a cordova plugin that might be helpful?
https://github.com/napolitano/cordova-plugin-intent

I have no idea where to start to get this on AGK
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 11th Mar 2018 20:07
If you rename your .apk file to .zip you can unzip it and modify the manifest
blurymind
7
Years of Service
User Offline
Joined: 25th Jun 2017
Location:
Posted: 12th Mar 2018 10:24 Edited at: 12th Mar 2018 10:26
@Blink0k that is all good, but how do we tell appgamekit app to get the path to the file or intent signal that was received by the andoid app manifest when initialized? Does this exist in the agk api? Are there any examples to look at or even plugins that do it?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Mar 2018 19:52
I don't think it's possible in Tier 1. Maybe in Tier 2
blurymind
7
Years of Service
User Offline
Joined: 25th Jun 2017
Location:
Posted: 12th Mar 2018 23:13
@blink0k
I have tier 2 and still think its impossible- at least for someone with limited knowledge of android's api and how the AGK's internals work.Not to mention my limited c++ knowledge.

Wouldnt it be great if there was an addon or a builtin method to do this?
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 12th Mar 2018 23:38 Edited at: 12th Mar 2018 23:40
This is possible in Teir 2 but you would have to do a lot of learning in android studio regarding how to handle intents correctly. You would have to respond to the startActivity() method and write the code to correctly respond to a ACTION_VIEW intent then get your C code to open the file in question and display it.

Unless your already proficient in Teir 2 on android and familiar with writing android studio apps then frankly It would take an awfully long time to explain exactly what yo have to do. It could take days!

As I said above though, you can use AGK's image chooser which is actually pretty good as it uses the inbuilt android viewer apps (like gallery or image view) to select an image which you can then open up and edit etc... Or you can start reading up on intents
blurymind
7
Years of Service
User Offline
Joined: 25th Jun 2017
Location:
Posted: 12th Mar 2018 23:41
@bengismo any explanation is highly appreciated.I am here to learn
Maybe with the help from this community we will have this one day
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
blurymind
7
Years of Service
User Offline
Joined: 25th Jun 2017
Location:
Posted: 14th Mar 2018 09:59 Edited at: 14th Mar 2018 10:00
@blink0k unfirtunatelly the AppGameKit Api doesnt seem to have any methods to interact or set android intents. I have no idea how to code this in tier2

Would be awesome to have though - especially for developing apps

Login to post a reply

Server time is: 2024-11-27 14:28:37
Your offset time is: 2024-11-27 14:28:37