Integrating Playphone SDK

Monkey Targets Forums/Android/Integrating Playphone SDK

Origaming(Posted 2012) [#1]
Hey guys,

We need help to integrating Playphone SDK to our first Android game. This is quite a challenge because we have least experience in working with Android native code.

We managed to get the code compiled and running without errors. But nothing happens.

Here's my basic java file for initializing their API. Any help is really appreciated! Thanks in advance!


import android.content.Intent;
import com.playphone.multinet.*;

/**
 * A class representing MultiNet "Direct" API.
 * MNDirect interface provides minimal set of methods required to enable
 * MultiNet functionality in application.
 */
class MNDirectMonkey extends Activity
{
  /**
   * Initializes MultiNet session and view.
   *
   * @param gameId       game id
   * @param gameSecret   game secret
   * @param eventHandler <code>MNDirect</code> events handler
   * @param activity     activity
   */
  public static void init (int gameId, String gameSecret)
   {
    MNDirect.init(gameId, gameSecret, new MNEventHandler(), MonkeyGame.activity);
    /* PlayPhone : Game Launcher functionality */
    MNDirect.handleApplicationIntent(MonkeyGame.activity.getIntent());
 
    /* PlayPhone : Initialize and Show the DashBoard button */
    MNDirectButton
        .initWithLocation(MNDirectButton.MNDIRECTBUTTON_TOPRIGHT);
    MNDirectButton.show();
 
    /* PlayPhone : Display PlayPhone Login Screen */
    MNDirectUIHelper.showDashboard();
 
    /* PlayPhone : Enable Banner notifications from PlayPhone SGN */
    MNDirectPopup.init(MNDirectPopup.MNDIRECTPOPUP_WELCOME
        | MNDirectPopup.MNDIRECTPOPUP_NEW_HI_SCORES
        | MNDirectPopup.MNDIRECTPOPUP_ACHIEVEMENTS);
    
   }
   
   public static class MNEventHandler extends MNDirectEventHandlerAbstract {
    /*
     * PlayPhone : This is required to ensure you can control the login workflow
     * behavior from the developer portal
     */
    @Override
    public void mnDirectViewDoGoBack() {
      MNDirectUIHelper.hideDashboard();
    }
    
    
  }
   
}



arawkins(Posted 2012) [#2]
Hey, you might be in luck, I just spent last weekend working on getting an android playphone module working in Monkey. I was able to get the PlayPhone dashboard up and managed to do some score submits. Just looking at your code, you could try adding this line right after MNDirect.init:

MNDirectUIHelper.setHostActivity(MonkeyGame.activity);


I've also uploaded my module here:

http://www.rawkins.com/playphone.zip

Maybe take a look and see if that makes more sense. I ended up using a static object to start up Playphone instead of trying to subclass Activity, not sure if that would make a difference in your case. If you are building your own Android activity, I think you need to manually tell Android to start your activity (I gave up at that point as I was getting a lot of errors). I'm no expert on Android or Java though so maybe someone else can help with that.

For starting up the module, I was calling StartPlayPhone() in my Apps Main method and the dashboard would appear. It didn't always work perfectly though; often I had to start the app from the device directly to get it to work (as opposed to building/running directly from Jungle or Ted).

I also had a lot of trouble getting all of the resources (jar files, drawables, etc.) into place in my build folder, and figuring out what to put in the manifest. If you are compiling without errors then I'm guessing you have that sorted out?

Anyways hope that helps, if you have any other questions I will do my best to answer them.


MikeHart(Posted 2012) [#3]
I was reading up on PlayPhone and found a lot of complains about PlayPhone, where they screwed phone users and charged them money. What do you think about Playphone?


c.k.(Posted 2012) [#4]
Mike, can you post some links of what you found? I'm still trying to figure out who to use for player and leaderboard management.


Origaming(Posted 2012) [#5]
Thanks, arawkins!
I can see from your code that you understand this stuff better than we do. Tried to run it, no errors during compilation, but still nothing happens when testing on Bluestacks and real device (my Tab P7300).

We merged the assets, libs and res folders from Playphone with the ones on \project.build\android\ folder. And force include the src by putting them inside \project.build\android\src\ and mark them as Read Only. So far no errors at all but at the same time, nothing happens. No dashboard whatsoever appears.

I suppose there's something missing on my manifest. I looked at the Integration guide and added these but they don't seem to have any effect:
      <activity
        android:configChanges="orientation|keyboard|keyboardHidden"
        android:label="${ANDROID_APP_LABEL}"
        android:name=".MonkeyGame" >
        <intent-filter >
           <action android:name="android.intent.action.MAIN" />
           <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity 
         android:name="com.playphone.multinet.core.MNProxyActivity"
         android:configChanges="orientation|keyboard|keyboardHidden">
      </activity>

There's definitely something missing here. Could you please point us out to some directions, arawkins?


MikeHart: Yes, I read about that too. But I believe that was something else, I mean, other Playphone products, and they happened in the past. What I see now is that Playphone is growing its catalog in Google Play at a great pace. Most of their games have positive reviews and their SDK is very robust. Integrating their SDK is supposedly an easy task, if we came from Android programming...


arawkins(Posted 2012) [#6]
@Origaming Have you added any permissions to your manifest? I have the following in /project.build/android/templates/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>


I also had to copy all of the .jar files into a subfolder (project.build/android/libs/extjavasources) and then add the following to project.build/android/build.xml, right before the closing </project>:

<copy todir="src">
  <fileset dir="libs/extjavasources"/>
</copy>


More details on that in this thread: http://www.monkeycoder.co.nz/Community/posts.php?topic=3377

Sorry I can't give you more concrete instructions, I went through a lot of trial and error getting it up and running and I am still figuring Android out. I also don't 100% understand how the build process works in Monkey and how it copies stuff from the different target and template folders when you build.

@MikeHart I haven't heard anything like that but would also be curious to see any links. So far my only experience with them has been integrating their SDK and it has been ok so far.


MikeHart(Posted 2012) [#7]
Here are some links:

http://iripoff.com/988/Playphone.com.html
http://forums.att.com/t5/Wireless-Billing/PlayPhone-Scam/td-p/1946445
https://www.google.de/search?q=playphone+user+fraud&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

I would hate it to use a service that would try to trick the user into signing a subscription for stuff.

Do you think it is save to use PlayPhone?


Origaming(Posted 2012) [#8]
Arawkins: It's alright, any kind of help is actually really appreciated.
I also encounter the same problem. No Libraries detected / included

-build-setup:
[echo] Resolving Build Target for MonkeyGame...
[gettarget] Project Target: Android 3.2
[gettarget] API level: 13
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: D:\runing.build\android\bin
[mkdir] Created dir: D:\runing.build\android\bin\res
[mkdir] Created dir: D:\runing.build\android\gen
[mkdir] Created dir: D:\runing.build\android\bin\classes
[echo] ----------
[echo] Resolving Dependencies for MonkeyGame...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
[dependency] API<=15: Adding annotations.jar to the classpath.
[echo] ----------
[echo] Building Libraries with 'debug'...
[subant] No sub-builds to iterate on



Using the suggested copy todir is not helpful in my case.

Maybe it's time for us to beg for help from the Mighty Mark? :)


Origaming(Posted 2012) [#9]
MikeHart, judging by the growing amount of apps published by Playphone each week, my gut tells me that they're probably a good choice to partner up with.
https://play.google.com/store/apps/developer?id=Playphone

Bad words go out and spread very quickly so we're very likely to hear bad things about company X as soon as they had their dirt uncovered. I've heard about Playphone surprising people with their hidden charges before, but up to this day, I haven't heard/read any developer complaining about them. Maybe some other guys could give you a different opinion.


arawkins(Posted 2012) [#10]
Have you sorted out how to read the debug log in Android with Logcat? If so you can do a test to see whether or not Playphone initializes. Something like this in your java code after you call MNDirect.init():

if (MNDirect.isOnline()) {
    Log.d("[Monkey]", "Playphone is running!");
} else {
    Log.d("[Monkey]", "Playphone is not running!");
}


Also are you testing on a real device? I haven't tried any of this on the emulator so I don't know if it works there.


arawkins(Posted 2012) [#11]
Oh sorry, just saw you posted your device above :)