04-01 23:14:37.843 32424-32424/org.androidtown.mylifecycle I/MainActivity: onCreate() 04-01 23:14:37.844 32424-32424/org.androidtown.mylifecycle I/MainActivity: onStart() 04-01 23:14:37.844 32424-32424/org.androidtown.mylifecycle I/MainActivity: onResume() 04-01 23:14:41.351 32424-32461/org.androidtown.mylifecycle E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f902286cd20 04-01 23:14:44.249 32424-32424/org.androidtown.mylifecycle I/MainActivity: onPause() 04-01 23:14:44.256 32424-32424/org.androidtown.mylifecycle I/MainActivity: onStop() 04-01 23:14:44.256 32424-32424/org.androidtown.mylifecycle I/MainActivity: onDestroy() 04-01 23:14:44.268 32424-32461/org.androidtown.mylifecycle E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f902286d650 04-01 23:14:48.916 32424-32424/org.androidtown.mylifecycle I/MainActivity: onCreate() 04-01 23:14:48.926 32424-32424/org.androidtown.mylifecycle I/MainActivity: onStart() 04-01 23:14:48.929 32424-32424/org.androidtown.mylifecycle I/MainActivity: onResume() 04-01 23:14:52.436 32424-32461/org.androidtown.mylifecycle E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f902286d1f0 |
class MainActivity
package org.androidtown.mylifecycle;
import android.app.Activity;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private final static String TAG ="MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(TAG, "onCreate()");
}
@Override
protected void onStart() {
super.onStart();
Log.i(TAG, "onStart()");
}
@Override
protected void onResume() {
super.onResume();
Log.i(TAG, "onResume()");
loadScore();
}
private void saveScore(){
SharedPreferences pref=getSharedPreferences("gostop", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor=pref.edit();
editor.putInt("score", 10000);
editor.commit();
}
private void loadScore(){
SharedPreferences pref=getSharedPreferences("gostop", Activity.MODE_PRIVATE);
int score =pref.getInt("score", 0);
Toast.makeText(getApplicationContext(), "onResume 읽어온 점수 :"+ score, Toast.LENGTH_LONG).show();
}
@Override
protected void onStop() {
super.onStop();
Log.i(TAG, "onStop()");
}
@Override
protected void onPause() {
super.onPause();
Log.i(TAG, "onPause()");
//종료 될때 자동 저장
saveScore();
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.i(TAG, "onDestroy()");
}
}
27강
28강
댓글 ( 4)
댓글 남기기