Open dkniffin opened 9 years ago
I just opened an issue with the BGG app, to add an intent to create a game.
I'm willing to work with the BGG guys if they want to make cross-app a possibility =)
I'm not very experienced with android development, but I took a stab at looking into this, and it might already be possible. I found this BroadcastReceiver
. @Mark-Lauman Maybe you can tell me if that does what we would need on the BGG app side?
I'm afraid that doesn't do much, I think it just allows that activity to change its playId when the active playId is changed by BGG.
For me to send a play to the BGG app, they'd need the following:
For BGG to launch Dominion Picker (without passing a game), they'd need these 2 lines of code:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("ca.marklauman.dominionpicker");
startActivity(launchIntent);
with some additional checks to verify that the app is installed.
For BGG to launch Dominion Picker and pass a set of cards, I'd need to do some more coding work on the SupplyActivity =)
Thanks! That helps a lot. I'm going to see if I can implement this on their side. I did a little android development 4 years ago or so, but haven't touched it since, so it'll be a learning experience.
For opening board game apps (eg Dominion Picker) from the BGG app, could it also be written as a generic Intent, sending something about the game that it want's to open? That way, if a new game app wants to support that interaction, the BGG doesn't have to code anything new.
Oh! Well that will make things considerably easier.
For argument passing, one possibility is me doing something like this:
Intent launchBGG = // make intent pointing to the BGG play activity
launchBGG.putExtra( KEY_TEXT, "text to display in the play");
startActivity(launchBGG);
Which you could then retrieve like this:
getIntent().getStringExtra( KEY_TEXT );
But if you find another way that works better, then use that - how I code is not necessarily how everyone should code :)
As for making the Intents generic, this seems possible. I know you can launch "generic email client" with this
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("message/rfc822");
intent.setData(Uri.parse("mailto:"+Uri.encode(target)+"?subject="+Uri.encode(subject)));
startActivity(Intent.createChooser(intent, "Send Email"));
but I haven't done my research, so I don't feel confident about how it works.
It'd be awesome if you could say you played with a set of cards, and have it log the play to boardgamegeek.com. You might also see if it could somehow integrate with the unofficial BGG app.