所以我刚刚开始使用新的Sony Xperia Tablet S Small App 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>发布于 2012-10-25 13:57:44
看起来你的代码没有什么问题。所以我认为问题在于你是如何构建项目的。更确切地说,是如何包含小应用程序框架的:它不应该包含在内!
如果您只需通过"Java build path“-> "Add external Jar”添加jar (来自Sony SDK),那么api jar的类将包含在应用程序中。问题是这些只是存根类,所以你可以得到两种可能的异常之一。
下面是一个简单快捷的方法来解决这个问题(仍然使用标准的android sdk,而不是切换到Sony SDK):
<代码>F29
使用此设置,小应用程序jar将仅在构建时使用。这对我来说很好。
发布于 2012-10-25 21:13:23
在服务标签中,将android:name="com.small.sonyapptest.MainApplication"更改为android:name="MainApplication"
发布于 2012-10-25 22:39:56
感谢您的回复,在将服务标签更改为MainApplication后,所有功能现在都可以正常工作。
https://stackoverflow.com/questions/13014207
复制相似问题