UKPixie
UKPixie

Reputation: 149

Sony Small App SDK

So i've just started to use the new Sony Xperia Tablet S Small App SDK. I'm no realy noob, developed many personal apps before but this has got me stumped.

I've loaded up the Sample project in Eclipse (all correctly configured), sorted some of the errors out, compiled to my device and when I launch the Small App from the launcher at the bottom of the device, it force closes - it's the same with every sample/app that I tried making with the SDK.

I'm attached below my MainApplication.java and AndroidManifest.xml in the hope that someone may be able to see where the issue lies. Don't understand as it's created as per the book. Any help really is appreciated please.

MainApplication.java:

package com.sony.thirdtest;

import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.view.View;
import android.widget.Toast;
import com.small.sonyapptest.R;
import com.sony.smallapp.SmallAppWindow;
import com.sony.smallapp.SmallApplication;

public class MainApplication extends SmallApplication {
    private Configuration mConfig;

    @Override
    public void onCreate() {
        super.onCreate();
        mConfig = new Configuration(getResources().getConfiguration());

        setContentView(R.layout.activity_main);
        setTitle(R.string.app_name);

        SmallAppWindow.Attributes attr = getWindow().getAttributes();
        attr.minWidth = 200;
        attr.minHeight = 200;
        attr.width = 400;
        attr.height = 300;
        attr.flags |= SmallAppWindow.Attributes.FLAG_RESIZABLE;
        getWindow().setAttributes(attr);

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainApplication.this, R.string.hello, Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onStop() {
        super.onStop();
    }

    @Override
    protected boolean onSmallAppConfigurationChanged(Configuration newConfig) {
        int diff = newConfig.diff(mConfig);
        mConfig = new Configuration(getResources().getConfiguration());
        // Avoid application from restarting when orientation changed
        if ((diff & ActivityInfo.CONFIG_ORIENTATION) != 0) {
            return true;
        }
        return super.onSmallAppConfigurationChanged(newConfig);
    }
}

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.small.sonyapptest" 
    android:versionCode="1" 
    android:versionName="1.0">
  <uses-sdk android:minSdkVersion="15" /> 


    <uses-permission android:name="com.sony.smallapp.permission.SMALLAPP" />

    <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">


        <uses-library android:name="com.sony.smallapp.framework" />

            <service 
                android:name="com.small.sonyapptest.MainApplication" 
                android:exported="true" >

            <intent-filter>

                <action android:name="com.sony.smallapp.intent.action.MAIN" />

                <category

                android:name="com.sony.smallapp.intent.category.LAUNCHER" />

                </intent-filter>

            </service>

    </application>
</manifest>

Upvotes: 3

Views: 1469

Answers (3)

Pete
Pete

Reputation: 605

In the service tag change android:name="com.small.sonyapptest.MainApplication" to android:name="MainApplication"

Upvotes: 1

UKPixie
UKPixie

Reputation: 149

Thanks for the responses, all working now after chaning the service tag to just MainApplication.

Upvotes: 0

Pal Szasz
Pal Szasz

Reputation: 3225

It seems that there is nothing wrong with your code. So I think the problem is with how you build the project. More exactly, how the small apps framework is included: it shouldn't be!

If you simply add the jar (from the Sony SDK) via "Java build path" -> "Add external Jar", then the classes of the api jar will be included with the application. The problem is those are only stub classes, so you can get one of two possible exceptions.

A simple and quick way to get around this (and still using the standard android sdk, and not switch to the Sony SDK) is the following:

  • Create a java project, and call it "SmallAppApi" for example
  • Inside the java project add the small app jar via "Add external jar"
  • In the last tab in the "Java build path" screen, called "Order and Export" make sure the small app jar is exported.
  • In the android project, in the "Java build path" screen, in "Projects" tab simply add the java project SmallAppApi (and remove the small app jar).

With this setup the small app jar will be used only when building. This worked fine for me.

Upvotes: 1

Related Questions