私は動作しているスプラッシュスクリーンの動作をしています。しかし、ユーザーが戻るボタンを押すと、アプリケーションを再開した後、私はスプラッシュスクリーンを表示したくありません。どうやってやるの ?スプラッシュスクリーンを表示する新鮮なオープン時のみ
SplashScreen.java
public class SplashScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Thread t = new Thread() {
public void run() {
try {
int time = 0;
while (time < 4000) {
sleep(100);
time += 100;
}
}
catch (InterruptedException e) {
// do nothing
}
finally {
Intent i = new Intent(SplashScreen.this, MainActivity.class);
startActivity(i);
finish();
}
}
};
t.start();
}
}
のAndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fardrop.radarso">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/app_theme">
<activity
android:name="com.fardrop.radarso.SplashScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:alwaysRetainTaskState="true"
android:icon="@mipmap/ic_launcher"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
</activity>
</application>
</manifest>
がhttps://stackoverflow.com/questions/20641580/show-splash-screen-one-time-only –
が共有県、チェックであなたのスプラッシュ画面の状態を保存参照してくださいさらに明確化のための答え下記を参照することができます それはspalsh画面のonCreateにあり、ユーザーがすでに訪問した場合は単にホーム画面に移動します –