unity3d - Include custom Activity inside of Unity Android Plugin (Without overriding UnityPlayerActivity)? -


i trying write android plugin unity3d interface google play in app billing. aware there existing plugins out there this, wish on own.

it appears need catch android's activity::onactivityresult handle successful purchase through gplay iab sdk. issue java class not contain activity because want run in background behind actual unity application.

this code gplay iab sdk initiates purchase flow. if pass "unityplayer.currentactivity" activity, google play pops up, , can purchase product. however, not receive successful message oniabpurchasefinishedlistener. if purchases unsuccessful (ie: own product) receive callback there.

public void launchpurchaseflow(activity act, string sku, string itemtype, int requestcode,                         oniabpurchasefinishedlistener listener, string extradata) ... ... act.startintentsenderforresult(pendingintent.getintentsender(),                                            requestcode, new intent(),                                            integer.valueof(0), integer.valueof(0),                                            integer.valueof(0)); 

full source here: http://pastebin.com/xwubrwtz

and here section google play in app billing sdk's (example code) posts successful callback (which not receiving)

/**      * handles activity result that's part of purchase flow in in-app billing. if      * calling {@link #launchpurchaseflow}, must call method      * activity's {@link android.app.activity@onactivityresult} method. method      * must called ui thread of activity.      *      * @param requestcode requestcode received it.      * @param resultcode resultcode received it.      * @param data data (intent) received it.      * @return returns true if result related purchase flow , handled;      *     false if result not related purchase, in case should      *     handle normally.      */     public boolean handleactivityresult(int requestcode, int resultcode, intent data) 

full source: http://pastebin.com/vtfxjhkx

here how google's example code processes onactivityresult callback:

@override     protected void onactivityresult(int requestcode, int resultcode, intent data) {         log.d(tag, "onactivityresult(" + requestcode + "," + resultcode + "," + data);          // pass on activity result helper handling         if (!mhelper.handleactivityresult(requestcode, resultcode, data)) {             // not handled, handle ourselves (here's you'd             // perform handling of activity results not related in-app             // billing...             super.onactivityresult(requestcode, resultcode, data);         }         else {             log.d(tag, "onactivityresult handled iabutil.");         }     } 

now, reason don't want override unityplayeractivity class (search "extending unityplayeractivity java code" on google, it's second link. lack of reputation prevents me posting direct link.) because requires modify androidmanifest.xml point new "launcher" - problem because several of existing ad platforms android require modify launcher point own java class. able co-exist these prevents me extending existing unity activity.

i attempted start own activity within java class (which spawned unity without issues) minimizes unity application , pulls blank activity - not want.

my question(s): can extend/catch/hook existing unityandroidplayer class , add onactivityresult function (it doesn't have 1 default).

if no, can make activity within android plugin doesn't take focus on phone?

if no, can modify code google play sdk (act.startintentsenderforresult(..)) notify me in different way?

if no, can do?

the best suggestion can give use export build option (this give eclipse workspace-worth of projects, ready run). unity's activities code - can hook own code them, without having subclass them. mean won't able use normal build , build , run builds (at least not when want test particular functionality), work. make process automatic on each build, can write post-build script in unity.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -