私はアプリに取り組んでいます。その ' 単一ページのストップウォッチ アプリ。したがって、ホームボタンを押して再度起動するか、実行中のアプリから実行すると、アプリの新しいインスタンスが作成されます。以前の現在実行中のインスタンスが必要です。
これをグーグルで調べたところ、起動モードを設定する必要があることがわかりました。というわけで、以下のようなことをしました。しかし、何も機能していません。それはまだ同じです。
<activity android:name=".MainActivity"
android:screenOrientation="portrait"
android:launchMode="singleTask"
>
@Override
protected Parcelable onSaveInstanceState()
{
Log.d(TAG, "onSaveInstanceState");
Bundle bundle = new Bundle();
bundle.putParcelable(INSTANCE_STATUS, super.onSaveInstanceState());
bundle.putDouble(STATUS_ANGLE, curAngle);
return bundle;
}
@Override
protected void onRestoreInstanceState(Parcelable state)
{
Log.d(TAG, "onRestoreInstanceState");
if (state instanceof Bundle)
{
Bundle bundle = (Bundle) state;
super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATUS));
curAngle= bundle.getDouble(STATUS_ANGLE);
curTime = (int) (60 / (2 * Math.PI) * curAngle* 60);
return;
}
super.onRestoreInstanceState(state);
}
もう1つ、タイマーに基づいています。アプリをバックグラウンドで実行する必要があるということですか?