Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 索尼小型应用程序SDK_Android_Tablet_Sony - Fatal编程技术网

Android 索尼小型应用程序SDK

Android 索尼小型应用程序SDK,android,tablet,sony,Android,Tablet,Sony,所以我刚刚开始使用新的索尼Xperia平板电脑的小应用程序SDK。我不是真正的傻瓜,以前开发过很多个人应用程序,但这让我很困惑 我已经在Eclipse中加载了示例项目(所有配置都正确),整理了一些错误,编译到我的设备中,当我从设备底部的启动器启动小应用程序时,它会强制关闭-我尝试使用SDK制作的每个示例/应用程序都是如此 下面是我的MainApplication.java和AndroidManifest.xml,希望有人能看到问题所在。不理解,因为它是根据书创建的。非常感谢您的帮助 MainAp

所以我刚刚开始使用新的索尼Xperia平板电脑的小应用程序SDK。我不是真正的傻瓜,以前开发过很多个人应用程序,但这让我很困惑

我已经在Eclipse中加载了示例项目(所有配置都正确),整理了一些错误,编译到我的设备中,当我从设备底部的启动器启动小应用程序时,它会强制关闭-我尝试使用SDK制作的每个示例/应用程序都是如此

下面是我的MainApplication.java和AndroidManifest.xml,希望有人能看到问题所在。不理解,因为它是根据书创建的。非常感谢您的帮助

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>

您的代码似乎没有问题。因此,我认为问题在于如何构建项目。更确切地说,小应用程序框架是如何包含的:不应该

如果您只是通过“Java构建路径”->“添加外部jar”添加jar(来自Sony SDK),那么api jar的类将包含在应用程序中。问题是这些只是存根类,所以您可以得到两种可能的异常之一

一个简单而快速的解决方法(仍然使用标准的android sdk,而不是切换到Sony sdk)如下所示:

  • 创建一个java项目,并将其称为“SmallAppApi”
  • 在java项目中,通过“添加外部jar”添加小型应用程序jar
  • 在“JavaBuildPath”屏幕的最后一个选项卡中,名为“Order and Export”,确保导出了小的应用程序jar
  • 在android项目中,在“Java构建路径”屏幕的“项目”选项卡中,只需添加Java项目SmallAppApi(并删除小应用程序jar)

通过这种设置,小的应用程序jar将仅在构建时使用。这对我来说很好。

在服务标签中,将安卓:name=“com.small.sonyapptest.MainApplication”更改为
安卓:name=“MainApplication”
感谢您的回复,在将服务标签更改为MainApplication之后,所有这些都可以正常工作。

那么答案就是上面@Pete给出的答案了吗?所以,接受他的回答并删除这个!