2018年3月18日日曜日

google AIY voice kit 組立・インストール・設定

google AIY voice kit 組立・インストール・設定

2018 Mar. 18.

google id (gmail address) を決める。

hotword・日本語・LED点滅設定解説: https://kureuetan.com/web/raspberrypi/4998/#Voice_Kit

(google-assistant実行)
${HOME}/AIY-projects-python/src/examples/voice/assistant_library_demo.py

(設定確認)
$ googlesamples-assistant-devicetool list --model
$ googlesamples-assistant-devicetool list --device

(PC起動時自動実行)
~/.config/lxsession/LXDE-pi/autostart に
実行スクリプトを次の形式で最下行に書き込む。
@lxterminal -e PATH/SCRIPT.sh

(実行スクリプト)
"~/bin/google-voice-hotword.sh"
#!/bin/bash --rcfile
# start google-AIY-voice-kit-hotword
${HOME}/AIY-projects-python/src/examples/voice/assistant_library_demo.py
echo "Google-AIY-voice-kit has finished."
exit 0

2018年2月18日日曜日

google drive内ファイルのアカウント間移動

google drive内ファイルのアカウント間移動

2018 Feb. 18.

(1)移動元アカウントにて
 ア.当該ファイルをアカウント先と共有にする。
 イ.当該ファイルの共有設定でそのファイルのオーナーを共有先アカウントに変更する。
   「共有 > 詳細設定」

(2)移動元アカウントにて
 移動元のアカウントを共有相手から削除。 「共有 > 詳細設定」

2018年2月11日日曜日

android開発 Messenger bindServiceの実行ポイント

android開発 Messenger bindServiceの実行ポイント

2018 Feb. 11.

bindServiceはActivityのonCreateコールバックの中で実行する。

例えば、ButtonのonClickコールバックの中で
bindService()してMessenger#send()
するとバインドに失敗する。


2018年1月21日日曜日

android AlertDialog内にinflateしたLayout内のViewへのアクセス

android AlertDialog内にinflateしたLayout内のViewへのアクセス

2018 Jan. 21.

Viewへのアスセスにはそれが所属するLayoutを指定する。


LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View myLayout = inflater.inflate(R.layout.my_layout, null);
TextView myTextView = (TextView)myLayout.findViewById(R.id.my_text_view);
myTextView.setText("Hello.");

android inflate先のレイアウトのないinflate

android inflate先レイアウトのないinflate

2018 Jan. 21.


サンプル1

LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View myView = inflater.inflate(R.layout.my_view, null);
setContentView(myView);


サンプル2

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btn = (Button)findViewById(R.id.button);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
                View titleView = inflater.inflate(R.layout.title_of_alert, null);
                builder.setCustomTitle(titleView);
                View descriptionView = inflater.inflate(R.layout.view_of_alert, null);
                builder.setView(descriptionView) ;
                builder.setPositiveButton("OK",
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Log.v("ok","Hi");
                        }
                    });
                AlertDialog dialog = builder.create();
                dialog.show();

            }
        });
    }
}

android Contextの取得

android Contextの取得

2018 Jan. 21.

HogeActivityのContextの取得

 AlertDialog.Builder(Context)でのContextの取得

  new AlertDialog.Builder(HogeActivity.this);

     getApplicationContext()ではエラーとなる。

2018年1月20日土曜日

SSH known_hostsファイル関連で Connection refused

2018 Sep. 01.

2018 Jan. 20.

$ ssh-keygen -R SERVER-ADDRESS
を実行する。
SERVER-ADDRESSはホスト名ではなくIPアドレスを指定する。
-R hostname
  Removes all keys belonging to hostname from a known_hosts file.
  This option is useful to delete hashed hosts (see the -H option
  above).