初心者っぽい質問のために私を銛にしないでください。
SL4Aを使用してAndroidアプリケーションで作業しています。アプリケーションが起動すると、スクリプトの実行中にバックグラウンドで実行されます。どこから始めればよいかわかりませんが、アイコンをクリックするたびに、アプリケーションが再起動します。何も変わらずに、さまざまな起動モードを使用してみました。OnCreateコードと通知の設定に関係していると思います。アプリケーションの状態を保存してから、アイコンを再度クリックするか、通知バーからクリックして再開するのにサポートが必要です。私は助けを求めてここに向かわなければならなかったすべてを試しました。私は決してアンドロイドプログラミングのプロではありません。みんなありがとう、優しくしてください;)
Public void onCreate() {
super.onCreate();
mInterpreterConfiguration = ((BaseApplication) getApplication())
.getInterpreterConfiguration();
}
@Override
public void onStart(Intent intent, final int startId) {
super.onStart(intent, startId);
String fileName = Script.getFileName(this);
Interpreter interpreter = mInterpreterConfiguration
.getInterpreterForScript(fileName);
if (interpreter == null || !interpreter.isInstalled()) {
mLatch.countDown();
if (FeaturedInterpreters.isSupported(fileName)) {
Intent i = new Intent(this, DialogActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra(Constants.EXTRA_SCRIPT_PATH, fileName);
startActivity(i);
} else {
Log
.e(this, "Cannot find an interpreter for script "
+ fileName);
}
stopSelf(startId);
return;
}
// Copies script to internal memory.
fileName = InterpreterUtils.getInterpreterRoot(this).getAbsolutePath()
+ "/" + fileName;
File script = new File(fileName);
// TODO(raaar): Check size here!
if (!script.exists()) {
script = FileUtils.copyFromStream(fileName, getResources()
.openRawResource(Script.ID));
}
copyResourcesToLocal(); // Copy all resources
if (Script.getFileExtension(this)
.equals(HtmlInterpreter.HTML_EXTENSION)) {
HtmlActivityTask htmlTask = ScriptLauncher.launchHtmlScript(script,
this, intent, mInterpreterConfiguration);
mFacadeManager = htmlTask.getRpcReceiverManager();
mLatch.countDown();
stopSelf(startId);
} else {
mProxy = new AndroidProxy(this, null, true);
mProxy.startLocal();
mLatch.countDown();
ScriptLauncher.launchScript(script, mInterpreterConfiguration,
mProxy, new Runnable() {
@Override
public void run() {
mProxy.shutdown();
stopSelf(startId);
}
});
}
}
RpcReceiverManager getRpcReceiverManager() throws InterruptedException {
mLatch.await();
if (mFacadeManager==null) { // Facade manage may not be available on startup.
mFacadeManager = mProxy.getRpcReceiverManagerFactory()
.getRpcReceiverManagers().get(0);
}
return mFacadeManager;
}
@Override
protected Notification createNotification() {
Notification notification =
new Notification(R.drawable.script_logo_48, this.getString(R.string.loading), System.currentTimeMillis());
// This contentIntent is a noop.
PendingIntent contentIntent = PendingIntent.getService(this, 0, new Intent(), 0);
notification.setLatestEventInfo(this, this.getString(R.string.app_name), this.getString(R.string.loading), contentIntent);
notification.flags = Notification.FLAG_ONGOING_EVENT;
return notification;
}