2019年7月11日木曜日

Understand the Activity Lifecycle 生命周期




生命周期

package com.kankanla.m20190711m_recorder;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends AppCompatActivity {
    private final String T = "###  MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.i(T, "1 onCreate");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void onStart() {
        Log.i(T, "2 onStart");
        super.onStart();
    }

    @Override
    protected void onResume() {
        Log.i(T, "3 onResume");
        super.onResume();
    }

    @Override
    protected void onPostResume() {
        Log.i(T, "4 onPostResume");
        super.onPostResume();
    }

    @Override
    protected void onPause() {
        Log.i(T, "5 onPause");
        super.onPause();
    }

    @Override
    protected void onStop() {
        Log.i(T, "6 onStop");
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        Log.i(T, "7 onDestroy");
        super.onDestroy();
    }

    @Override
    protected void onRestart() {
        Log.i(T, "8 onRestart");
        super.onRestart();
    }
}





2019年7月7日日曜日

自動バックアップ

自動バックアップ
SharedPreferencesが再インストール時にリセットされない

bmgr
https://stuff.mit.edu/afs/sipb/project/android/docs/tools/help/bmgr.html

Auto Backup for Android codelab
https://codelabs.developers.google.com/codelabs/android-backup-codelab/#0

Data backup overview
https://developer.android.com/guide/topics/data/backup

<manifest
    <application
         android:allowBackup="true"

adb shell bmgr enabled
adb shell bmgr enable <true|false>
adb shell bmgr list transports
adb shell bmgr backupnow <PACKAGE>
adb shell bmgr backup <PACKAGE>
adb shell bmgr run

adb shell bmgr restore <TOKEN> <PACKAGE>










2019年7月5日金曜日

adb shell dumpsys jobscheduler

adb shell dumpsys jobscheduler


Active jobs:
  Slot #0: inactive since -9m38s404ms, stopped because: app called jobFinished
  Slot #1: inactive since -11m39s487ms, stopped because: cancel() called by app, callingUid=10049 uid=10049 jobId=43
  Slot #2: inactive since -11m39s594ms, stopped because: cancel() called by app, callingUid=10049 uid=10049 jobId=183
  Slot #3: inactive since -3h35m29s108ms, stopped because: last work dequeued
  Slot #4: inactive since -3h45m4s586ms, stopped because: last work dequeued
  Slot #5: inactive since -3h45m4s848ms, stopped because: app called jobFinished
  Slot #6: inactive
  Slot #7: inactive
  Slot #8: inactive
  Slot #9: inactive
  Slot #10: inactive
  Slot #11: inactive
  Slot #12: inactive
  Slot #13: inactive
  Slot #14: inactive
  Slot #15: inactive

mReadyToRock=true
mReportedActive=false
mMaxActiveJobs=6

PersistStats: FirstLoad: 78/11/9 LastSave: 67/6/4