編輯:Android開發教程
Activity代碼:
public class FiveActivity extends AppCompatActivity { private MyView myView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.e("log", "Activity生命周期:onCreate"); setContentView(R.layout.activity_five); initView(); } private void initView() { myView = (MyView) findViewById(R.id.my_view); } @Override protected void onStart() { super.onStart(); Log.e("log", "Activity生命周期:onStart"); } @Override protected void onResume() { super.onResume(); Log.e("log", "Activity生命周期:onResume"); } @Override protected void onRestart() { super.onRestart(); Log.e("log", "Activity生命周期:onRestart"); } @Override protected void onPause() { super.onPause(); Log.e("log", "Activity生命周期:onPause"); } @Override protected void onStop() { super.onStop(); Log.e("log", "Activity生命周期:onStop"); } @Override protected void onDestroy() { super.onDestroy(); Log.e("log", "Activity生命周期:onDestroy"); } }
自定義View代碼:
public class MyView extends View { public MyView(Context context, AttributeSet attrs) { super(context, attrs); Log.e("log", "onCreate"); } @Override protected void onFinishInflate() { super.onFinishInflate(); Log.e("log", "onFinishInflate"); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); Log.e("log", "onAttachedToWindow"); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); Log.e("log", "onMeasure"); } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); Log.e("log", "onSizeChanged"); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); Log.e("log", "onLayout"); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Log.e("log", "onDraw"); } @Override public void onWindowFocusChanged(boolean hasWindowFocus) { super.onWindowFocusChanged(hasWindowFocus); Log.e("log", "onWindowFocusChanged" + " " + hasWindowFocus); } }
我們都知道,Android上的界面展示都是通過Activity實現的,Activity實在是太常用了,我相信大家都 已經非常熟悉了,這裡就不再贅述。但是Activity也
Android 手機使用Pattern圖案加密後,如果忘記密碼或多次解鎖失敗後,會被google自動鎖定,無法再次進入開機首頁。本文就是針對這種情況,研究探索了一種解決的
前面介紹了Android測試的一些理論知識,從本篇開始的幾篇將結合ApiDemoTest示例來介紹Android測試的實例。在此之前可 以參照Android測試教程(3)
使用Android系統最大的優點就是刷機,並且良好的兼容性和自由的可擴展性成為開發者的“樂土”,比如CM等自定義ROM,那麼你有沒有想過將Andr