PDA

View Full Version : نشان ندادن splashscreen برای بارهای بعد



daniel021
یک شنبه 22 تیر 1393, 13:10 عصر
من میخوام splashscreen تو شیرد پریفرنس ذخیره شه و دیگه واسه بار های بعدی دیگه نشون نده

این کد splash screen :


;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;
public class SplashScreen extends Activity {
private int _splashTime = 5000;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);

getWindow().setFlags(WindowManager.LayoutParams.FL AG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

new Handler().postDelayed(new Thread(){
@Override
public void run(){
Intent mainMenu = new Intent(SplashScreen.this, Main.class);
SplashScreen.this.startActivity(mainMenu);
SplashScreen.this.finish();
overridePendingTransition(R.drawable.fadein, R.drawable.fadeout);
}
}, _splashTime);
}
}

smemamian
یک شنبه 22 تیر 1393, 13:43 عصر
شما نمی توانید از این intent برای دو Activity استفاده کنید:

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

به همین خاطر شما از یک کلاس واسط استفاده کنید و در داخل اون کلاس از یک SharedPreferences (http://developer.android.com/reference/android/content/SharedPreferences.html)
کمک بگیرید که آیا بار اول هست یا نه اگه آره اجرا کن اگر نه Activity اصلی رو اجرا کن.