简体   繁体   English

索尼小应用程序SDK

[英]Sony Small App SDK

So i've just started to use the new Sony Xperia Tablet S Small App SDK. 所以我刚刚开始使用新的Sony Xperia Tablet S Small App SDK。 I'm no realy noob, developed many personal apps before but this has got me stumped. 我不是真正的noob,之前开发了许多个人应用程序,但这让我感到难过。

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. 我已经在Eclipse中加载了Sample项目(所有配置正确),将一些错误排序,编译到我的设备,当我从设备底部的启动器启动Small App时,它会强制关闭 - 这是与我尝试使用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. 我附在我的MainApplication.java和AndroidManifest.xml下面,希望有人能够看到问题所在。 Don't understand as it's created as per the book. 不明白,因为它是根据本书创建的。 Any help really is appreciated please. 任何帮助真的很感激。

MainApplication.java: 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 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>

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. 如果您只是通过“Java构建路径” - >“添加外部Jar”添加jar(来自Sony SDK),那么api jar的类将包含在应用程序中。 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: 一个简单快捷的解决方法(仍然使用标准的android sdk,而不是切换到Sony SDK)如下:

  • Create a java project, and call it "SmallAppApi" for example 创建一个java项目,并将其称为“SmallAppApi”
  • Inside the java project add the small app jar via "Add external jar" 在java项目中通过“添加外部jar”添加小app jar
  • In the last tab in the "Java build path" screen, called "Order and Export" make sure the small app jar is exported. 在“Java构建路径”屏幕的最后一个选项卡中,称为“订单和导出”,确保导出小型应用程序jar。
  • 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). 在android项目中,在“Java构建路径”屏幕的“项目”选项卡中,只需添加java项目SmallAppApi(并删除小应用程序jar)。

With this setup the small app jar will be used only when building. 使用此设置,小型app jar将仅在构建时使用。 This worked fine for me. 这对我来说很好。

在服务标签android:name="com.small.sonyapptest.MainApplication"更改为android:name="MainApplication"

感谢您的回复,现在所有人都在将服务标签转换为MainApplication后工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM