x


Accessing Data from a Android java class

I am trying to access what level that has been choosen when starting the Unity application. Unity is started from my (Android java) UnityPlay class. I want to know what button that was pressed to launch Unity to know what scene to load.

The UnityPlay class:

package com.company.project;
    ...
    public class UnityPlay extends UnityPlayerActivity{

    public String selectedItem;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    public String getSelectedItem() {
        selectedItem = "levelname";
       return selectedItem;
       }
}

In Unity a script is created and added to a object:

function Start() {
    yield WaitForSeconds(3.0);
    var jo = new AndroidJavaObject("com.company.project.UnityPlay");
    var level = jo.Call.<String>("getSelectedItem");

    Application.LoadLevel(level);
}

As far as I can see the return value of the request is null or a blank String "".

more ▼

asked Sep 20 '11 at 04:57 PM

mrt gravatar image

mrt
1 1 2 2

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2611
x302
x15

asked: Sep 20 '11 at 04:57 PM

Seen: 1189 times

Last Updated: Sep 20 '11 at 04:57 PM