0

I want that task is eseguite only time. When i return in this activity doesn't eseguite

public void onStart() {
    super.onStart();
    if (mMovies.le) {
        TaskClass nuovo = new TaskClass();
        nuovo.execute("http://api.themoviedb.org/3/discover/movie?sort_by=popularity.desc&");
        Log.v("prova", "inizio");
    }

}

1 Answers1

0

You have to use a SharedPreferences like this:

final String PREFS_NAME = "MyPrefsFile";
SharedPreferences firstPref = getSharedPreferences(PREFS_NAME, 0);
if (firstPref.getBoolean("First_Time", true)) {   
  //Do first operation
  if (mMovies.le) {
      TaskClass nuovo = new TaskClass();
      nuovo.execute("http://api.themoviedb.org/3/discover/movie?sort_by=popularity.desc&");
      Log.v("prova", "inizio");
  }      
  firstPref.edit().putBoolean("First_Time", false).commit(); 
}

In onCreate() method of your Activity

Michele Lacorte
  • 5,323
  • 7
  • 32
  • 54