could anyone tell me how can slove problem that [ how to show Activity of android in Layer of cocos2dx ] ?

as title, i want to display some android elements.

just like google map, how could i show it in Layer of cocos2dx?

please tell me how could i do…

thank you very much :slight_smile: :slight_smile:

Have a look at the google map integration guide and it will tell you about how to create the “google map view”.

In your myapp.java file find your “protected void onCreate(Bundle savedInstanceState)” function. You can create a sub-layout and add the “google map view” to this and this will be shown on top of your cocos2d-x view. Here is some code that might work (I’m just making up the code to make the google map view as I have’t looked for it, the code to make the layout should work fine, it works for me for other things):-

GoogleMapView gmView;    // this line is made up - replace with real google map example code
gmView = new GoogleMapView(this);  // this line is made up - replace with real google map example code
gmView.init( this, mygooglemapid);   // this line is made up - replace with real google map example code

LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(
    getWindowManager().getDefaultDisplay().getWidth(), -100);              // position of the view
LinearLayout subLayout = new LinearLayout(this);
subLayout.setOrientation(LinearLayout.VERTICAL);
subLayout.setBackgroundColor(Color.TRANSPARENT);
subLayout.setGravity(Gravity.CENTER);               
gmapsContentView(subLayout, llParams);         
gmapsViewContainer = subLayout;
gmapsViewContainer.addView(gmView);

Gav GMTDev wrote:

Have a look at the google map integration guide and it will tell you about how to create the “google map view”.
>
In your myapp.java file find your “protected void onCreate(Bundle savedInstanceState)” function. You can create a sub-layout and add the “google map view” to this and this will be shown on top of your cocos2d-x view. Here is some code that might work (I’m just making up the code to make the google map view as I have’t looked for it, the code to make the layout should work fine, it works for me for other things):-
>
[…]

so i call myapp.java if i want to show google map?
Does user click events can deliver normally?
I would try after work… wait for good news…

e.j. yue wrote:

Gav GMTDev wrote:
> Have a look at the google map integration guide and it will tell you about how to create the “google map view”.
>
> In your myapp.java file find your “protected void onCreate(Bundle savedInstanceState)” function. You can create a sub-layout and add the “google map view” to this and this will be shown on top of your cocos2d-x view. Here is some code that might work (I’m just making up the code to make the google map view as I have’t looked for it, the code to make the layout should work fine, it works for me for other things):-
>
> […]
>
so i call myapp.java if i want to show google map?
Does user click events can deliver normally?
I would try after work… wait for good news…

Go into the “proj.android” folder of your project, then into the “src” folder and into any sub-folders. You’ll find your “.java” file in there. Look for that OnCreate function I told you about.

You create the Google Map view and display it there. If you then need to send it messages/command you’ll need to use JNI to call Java code from your Cocos2d-x C++ code, have a look at this thread for an example of it: http://www.cocos2d-x.org/boards/6/topics/3769