/images/avatar.png

^_^

杀手2

杀手2由IO Interactive开发,2018年发行的潜行刺杀游戏,与羞辱不同的是这是第三人称

https://img-blog.csdnimg.cn/20200328175706409.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70

杀手2最大的特点是刺杀方法的丰富性

Android 属性动画

简单演示

https://img-blog.csdnimg.cn/20200323221512658.gif

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".anim2Activity">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:id="@+id/a2tv1"
        android:textSize="30sp"
        android:text="animation_test"
        android:gravity="center"
        android:textColor="#FFFFFF"
        android:background="#AAAAAA"/>
</androidx.constraintlayout.widget.ConstraintLayout>
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
package com.example.test;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.TextView;

public class anim2Activity extends AppCompatActivity {
    private TextView a2tv1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_anim2);
        a2tv1 = findViewById(R.id.a2tv1);
        a2tv1.animate().translationYBy(500).setDuration(2000).start();
    }
}

https://img-blog.csdnimg.cn/20200324104958404.gif

看门狗2

Watch_dogs2是ubisoft于2016年11月发行的角色扮演游戏

https://img-blog.csdnimg.cn/20200324223722585.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70

骇入系统是其游戏特色

玩了130+小时

看门狗2的这个特色很新颖,但是剧情很平淡,后面的玩法基本与前面重复

Android 数据存储

SharedPreferences

https://img-blog.csdnimg.cn/20200322213737854.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70#pic_center

sharedpreferences的布局

https://img-blog.csdnimg.cn/20200322214132290.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70

布局文件

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".datastorage.sharedPreferencesActivity">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/spet1"
        android:hint="input"
        android:textSize="25sp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintVertical_bias="0.1"
        />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="25sp"
        android:text="sava"
        app:layout_constraintTop_toBottomOf="@+id/spet1"
        android:layout_marginTop="20dp"
        android:id="@+id/spbtn1"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="25sp"
        android:text="show"
        app:layout_constraintTop_toBottomOf="@+id/spbtn1"
        android:layout_marginTop="20dp"
        android:id="@+id/spbtn2"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/sptv1"
        android:textSize="25sp"
        app:layout_constraintTop_toBottomOf="@+id/spbtn2"
        android:layout_marginTop="20dp"
        />


</androidx.constraintlayout.widget.ConstraintLayout>

输入内容,存储到sharedpreferences,并呈现

Android 事件处理机制

事件处理

https://img-blog.csdnimg.cn/20200319125011916.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70 https://img-blog.csdnimg.cn/20200319125041979.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70 https://img-blog.csdnimg.cn/20200319125148988.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70

基于监听的事件处理机制

匿名内部类

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
mbt1.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()){
                    case MotionEvent.ACTION_DOWN:
                        Log.d("listener","touch");
                        break;
                }
                return false;
            }
        });

事件源所在类(activity类)

1
public class eventActivity extends AppCompatActivity implements View.OnClickListener
1
2
ebt1 = findViewById(R.id.ebt1);
        ebt1.setOnClickListener(eventActivity.this);
1
2
3
4
5
6
7
8
@Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ebt1:
                Toast.makeText(eventActivity.this , "click...",Toast.LENGTH_LONG).show();
                break;
        }
    }

在布局文件中设置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<Button
        android:id="@+id/ebt1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="click"
        android:textSize="20sp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="50dp"
        android:onClick="show"
        />
1
2
3
4
5
6
7
public void show(View view){             //一定是public void
        switch (view.getId()){
            case R.id.ebt1:
                Toast.makeText(eventActivity.this , "click...",Toast.LENGTH_LONG).show();
                break;
        }
    }

https://img-blog.csdnimg.cn/20200319131750142.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70

Android 四大组件之Activity

Activity

https://img-blog.csdnimg.cn/2020031908390495.PNG https://img-blog.csdnimg.cn/20200319083947645.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70 https://img-blog.csdnimg.cn/20200319084012872.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70

activity的生命周期

https://img-blog.csdnimg.cn/20200318214923967.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70

运行以下代码可以看到activity经历的生命周期

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.example.test;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

public class lifeCircleActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_life_circle);
        Log.d("lifecircle","-----onCreate----");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.d("lifecircle","-----onStart----");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d("lifecircle","-----onResume----");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d("lifecircle","-----onPause----");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d("lifecircle","-----onStop----");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.d("lifecircle","-----onRestart----");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d("lifecircle","-----onDestroy----");
    }

}

启动这个activity之后

Android 四大组件之Content Provider

Content Provider

https://img-blog.csdnimg.cn/20200319153118615.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70 https://img-blog.csdnimg.cn/20200319153232133.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70 https://img-blog.csdnimg.cn/20200319153348737.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70 https://img-blog.csdnimg.cn/20200319153425979.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70 https://img-blog.csdnimg.cn/20200319153505783.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70 https://img-blog.csdnimg.cn/20200319153534803.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70

获取外部应用的信息

以获取通讯录为例

布局文件

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".contentProviderActivity">

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/cpbtn1"
        android:textSize="25sp"
        android:text="get_contacts"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/cpbtn2"
        android:text="getdata"
        android:textSize="25dp"
        app:layout_constraintTop_toBottomOf="@+id/cpbtn1"
        android:layout_marginTop="20dp"/>

</androidx.constraintlayout.widget.ConstraintLayout>

点击get_contacts获取联系人信息