SDL Forum Index
SDL
Simple DirectMedia Layer Forums
Reply to topic
Android: project name different from SDLActivity?
wboe


Joined: 09 Jan 2012
Posts: 41
Location: Amsterdam, Netherlands
Reply with quote
Hi,

Using SDL for Android, you are supposed to call your project SDLActivity, because this name is hard-coded in SDL/src/core/android/SDL_android.cpp. This means that you only can install one SDL app on your phone or tablet. If you try to install another, with a different name (specified in the res/values/strings.xml file), it will overwrite the first app. How are you supposed to prevent this?

wboe
View user's profileSend private messageVisit poster's website
Android: project name different from SDLActivity?
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
Reply with quote
El oct 7, 2012 12:37 p.m., "wboe" escribió:
Quote:

Hi,

Using SDL for Android, you are supposed to call your project SDLActivity, because this name is hard-coded in SDL/src/core/android/SDL_android.cpp. This means that you only can install one SDL app on your phone or tablet. If you try to install another, with a different name (specified in the AndroidManifest.xml file), it will overwrite the first app. How can this be prevented?


This may help you http://mdqinc.com/blog/2011/11/using-your-own-app-name-in-a-sdl-android-app/

_________________
Gabriel Jacobo
mdqinc.com
View user's profileSend private messageVisit poster's website
josebagar


Joined: 10 Dec 2010
Posts: 87
Reply with quote
Hi,

I'm using a different approach to this. I'm referencing my activity from AndroidManifest.xml and then create a new class with a very few lines of code:
Code:
package org.bennugd.samplegame;

import org.libsdl.app.SDLActivity;
import android.os.*;

/*
 * A sample wrapper class that just calls SDLActivity
 */

public class MyGame extends SDLActivity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
   
    protected void onDestroy() {
        super.onDestroy();
    }
}

AndroidManifest.xml looks like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="org.bennugd.samplegame"
      android:versionCode="1"
      android:versionName="1.0">
        <application android:label="@string/app_name" android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <activity android:name="MyGame"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="9" />
    <uses-feature android:glEsVersion="0x00020000" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>


And I can use all of SDL2's code without any modification. It seems to be working fine but I'm pretty new to Java, so I might be missing something.

Regards and hope this is helpful.
View user's profileSend private message
wboe


Joined: 09 Jan 2012
Posts: 41
Location: Amsterdam, Netherlands
Reply with quote
The solution from josebagar works, it is simple and elegant. Thanks!

One small addition: in the ant build file the line
<project name="SDLActivity" default="help">
should be modified to
<project name="MyGame" default="help">

wboe

PS
Vivat SDL for Android! If you code in C++11, then it's better and easier then android's own java toolbox!
View user's profileSend private messageVisit poster's website
josebagar


Joined: 10 Dec 2010
Posts: 87
Reply with quote
wboe wrote:
The solution from josebagar works, it is simple and elegant. Thanks!

One small addition: in the ant build file the line
<project name="SDLActivity" default="help">
should be modified to
<project name="MyGame" default="help">

wboe

PS
Vivat SDL for Android! If you code in C++11, then it's better and easier then android's own java toolbox!
Thanks for the note Smile

If the approach is correct and people like it, it might be a good idea to add the instructions to README.android as this will probably be of interest to a lot of people in the future.
View user's profileSend private message
Android: project name different from SDLActivity?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic