diff --git a/soft1614080902434/2.app/2.app/src/main/AndroidManifest.xml b/soft1614080902434/2.app/2.app/src/main/AndroidManifest.xml
index cf8b69516..cf0d2cfd1 100644
--- a/soft1614080902434/2.app/2.app/src/main/AndroidManifest.xml
+++ b/soft1614080902434/2.app/2.app/src/main/AndroidManifest.xml
@@ -1,6 +1,12 @@
+ package="soft1614080902434.androidlabs.hzuapps.edu.soft1614080902434">
+
+
+
+
+
+
-
+
+
+
\ No newline at end of file
diff --git a/soft1614080902434/2.app/2.app/src/main/java/edu/hzupps/androidlabs/soft1614080902434/Second_Activity.java b/soft1614080902434/2.app/2.app/src/main/java/edu/hzupps/androidlabs/soft1614080902434/Second_Activity.java
index ab0e6e7e4..e9f6f3c8d 100644
--- a/soft1614080902434/2.app/2.app/src/main/java/edu/hzupps/androidlabs/soft1614080902434/Second_Activity.java
+++ b/soft1614080902434/2.app/2.app/src/main/java/edu/hzupps/androidlabs/soft1614080902434/Second_Activity.java
@@ -1,44 +1,118 @@
package soft1614080902434.androidlabs.hzuapps.edu.soft1614080902434;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.Environment;
+import android.os.Handler;
+import android.os.Message;
+import android.support.annotation.RequiresPermission;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
import android.widget.TextView;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+
public class Second_Activity extends AppCompatActivity implements View.OnClickListener {
- TextView t[] = new TextView[12];
+ EditText ed;
+ Button send,down;
+ public TextView text;
+ private ImageView imageview;
+ private Bitmap bitmap;
+ Handler handler=new Handler(){
+ public void handleMessage(Message msg) {
+ if(msg.what==123){
+ imageview.setImageBitmap(bitmap);
+ }
+ };
+ };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second_);
+ this.RegisterEcent();
}
public void RegisterEcent(){
- t[0]=(TextView) findViewById(R.id.n_0);
- t[1]=(TextView) findViewById(R.id.n_1);
- t[2]=(TextView) findViewById(R.id.n_2);
- t[3]=(TextView) findViewById(R.id.n_3);
- t[4]=(TextView) findViewById(R.id.n_4);
- t[5]=(TextView) findViewById(R.id.n_5);
- t[6]=(TextView) findViewById(R.id.n_6);
- t[7]=(TextView) findViewById(R.id.n_7);
- t[8]=(TextView) findViewById(R.id.n_8);
- t[9]=(TextView) findViewById(R.id.n_9);
- t[10]=(TextView) findViewById(R.id.n_10);
- t[11]=(TextView) findViewById(R.id.n_11);
- t[12]=(TextView) findViewById(R.id.n_12);
- t[13]=(TextView) findViewById(R.id.n_13);
- t[14]=(TextView) findViewById(R.id.n_14);
- t[15]=(TextView) findViewById(R.id.n_15);
- t[16]=(TextView) findViewById(R.id.n_16);
- for(int i=0;i<17;i++){
- t[i].setOnClickListener(this);
- }
-
+ down = (Button)findViewById(R.id.Down);
+ down.setOnClickListener(this);
+ imageview=(ImageView) findViewById(R.id.image);
+ text = (TextView)findViewById(R.id.address);
+ ed = (EditText)findViewById(R.id.edit_text);
+ send = (Button)findViewById(R.id.n_12);
+ send.setOnClickListener(this);
+ Log.d("dd","789");
}
- @Override
- public void onClick(View v) {
+ public void save(String str){
+ String data=str;
+ FileOutputStream out=null;
+ BufferedWriter writer=null;
+
+ try{
+ out =openFileOutput("wechat", Context.MODE_PRIVATE);
+ writer=new BufferedWriter(new OutputStreamWriter(out));
+ Log.d("dd","456");
+ writer.write(data);
+ } catch(IOException e){
+ e.printStackTrace();
+ } finally {
+ if (writer !=null){
+ try {
+ writer.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
}
+ @Override
+ public void onClick(View view){
+ if(view==send) {
+ String str = ed.getText().toString();
+ this.save(str);
+ Log.d("dd", "123");
+ }
+ if(view==down){
+ new Thread(download).start();
+ }
+ }
+ Thread download = new Thread(){
+
+ public void run() {
+ String Path=text.getText().toString();//下载图片的路径
+ try {
+ URL url=new URL(Path);//对资源链接
+ InputStream inputStream=url.openStream();
+ bitmap= BitmapFactory.decodeStream(inputStream);//转换成位图图片
+ handler.sendEmptyMessage(123);
+ inputStream.close();
+ inputStream=url.openStream();
+ File file=new File(Environment.getExternalStorageDirectory()+"./DCIM/wechat.jpg");
+ FileOutputStream fileOutputStream=new FileOutputStream(file);
+ int hasRead=0;
+ while((hasRead=inputStream.read())!=-1){
+ fileOutputStream.write(hasRead);
+ }
+ fileOutputStream.close();
+ inputStream.close();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ };
}
diff --git a/soft1614080902434/2.app/2.app/src/main/res/layout/activity_second_.xml b/soft1614080902434/2.app/2.app/src/main/res/layout/activity_second_.xml
index 0c1c6934c..00d993669 100644
--- a/soft1614080902434/2.app/2.app/src/main/res/layout/activity_second_.xml
+++ b/soft1614080902434/2.app/2.app/src/main/res/layout/activity_second_.xml
@@ -10,7 +10,7 @@
android:layout_width="match_parent"
android:layout_height="304dp"
android:layout_x="0dp"
- android:layout_y="2dp"
+ android:layout_y="0dp"
android:background="#EBEBEB"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="0dp" />
@@ -142,6 +142,7 @@
android:layout_x="269dp"
android:layout_y="262dp"
android:text="发送"
+ android:clickable="true"
tools:layout_editor_absoluteX="298dp"
tools:layout_editor_absoluteY="538dp" />
@@ -165,15 +166,6 @@
tools:layout_editor_absoluteX="340dp"
tools:layout_editor_absoluteY="212dp" />
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/soft1614080902434/2.app/2.app/src/main/res/layout/activity_wechat.xml b/soft1614080902434/2.app/2.app/src/main/res/layout/activity_wechat.xml
index 5c1b9ffdc..515bfdb4c 100644
--- a/soft1614080902434/2.app/2.app/src/main/res/layout/activity_wechat.xml
+++ b/soft1614080902434/2.app/2.app/src/main/res/layout/activity_wechat.xml
@@ -33,6 +33,7 @@
android:layout_x="243dp"
android:layout_y="293dp"
android:text="表情包"
+ android:clickable="true"
tools:layout_editor_absoluteX="262dp"
tools:layout_editor_absoluteY="47dp" />
diff --git a/soft1614080902434/5.1.png b/soft1614080902434/5.1.png
new file mode 100644
index 000000000..5b5541cd1
Binary files /dev/null and b/soft1614080902434/5.1.png differ
diff --git a/soft1614080902434/5.2.png b/soft1614080902434/5.2.png
new file mode 100644
index 000000000..8fbbea7a2
Binary files /dev/null and b/soft1614080902434/5.2.png differ
diff --git a/soft1614080902434/6.1.png b/soft1614080902434/6.1.png
new file mode 100644
index 000000000..37c6414eb
Binary files /dev/null and b/soft1614080902434/6.1.png differ
diff --git a/soft1614080902434/6.2.png b/soft1614080902434/6.2.png
new file mode 100644
index 000000000..7b9d489a0
Binary files /dev/null and b/soft1614080902434/6.2.png differ
diff --git a/soft1614080902434/report5.md b/soft1614080902434/report5.md
new file mode 100644
index 000000000..f9a158fca
--- /dev/null
+++ b/soft1614080902434/report5.md
@@ -0,0 +1,27 @@
+# 第五次实验
+
+## 1.实验目的
+
+Android存储编程
+## 2.实验步骤
+1.打开实验4的工程项目,我要存储发送出去的数据,我做的是内部存储。
+
+
+2.用到两个关键字: FileOutputStream和BufferedWriter writer。
+
+3.把按钮“发送”作为监听器,当你写上一些数据时,然后点击“发送”,系统此时就自动存储数据.
+
+4.运行程序,然后从Android上面一排的View-Tool Windows-Device File Explorer,在这里找到soft1614080902434里面的File。
+
+5.git push.并pull request.
+
+
+## 3.实验结果
+运行截图:
+![Image text](https://github.com/Min4396/android-labs-2018/blob/master/soft1614080902434/5.1.png)
+![Image text](https://github.com/Min4396/android-labs-2018/blob/master/soft1614080902434/5.2.png)
+
+
+## 4.实验心得
+ 这次实验还是比较难,因为我对存储文件很陌生,然后,我查看了一些课外书,找到了一些方法,一开始我运行之后,发现存储不了,找不到原因,然后就在别人的电脑运行,结果可以,然后我回到自己的电脑运行,结果可以了,这个,我学到了一点存储的方法。
+
diff --git a/soft1614080902434/report6.md b/soft1614080902434/report6.md
new file mode 100644
index 000000000..2a9f60da2
--- /dev/null
+++ b/soft1614080902434/report6.md
@@ -0,0 +1,27 @@
+# 实验6
+## 一、实验目的
+
+掌握Android网络访问方法。
+
+## 二、实验内容
+
+从百度上寻找一张网址以后缀名为.jpg的图片,把图片的网址放到activity_second_xml文件中。
+
+## 三、实验步骤
+1.AndroidManifest.xml中添加能够写入读出内存空间权限和网络连接权限的代码。
+
+2.然后在activity_second_xml中添加一个新的按钮和一个TextView,是用来显示图片的,按钮用来监听。
+
+3.在Second_Activity中写一个线程函数,用来管理下载和显示的图片。
+
+4.编译运行,然后push。
+
+
+## 四.实验截图
+![Image text](https://github.com/Min4396/android-labs-2018/blob/master/soft1614080902434/6.1.png)
+![Image text](https://github.com/Min4396/android-labs-2018/blob/master/soft1614080902434/6.2.png)
+
+
+## 五.实验心得
+这次实验主要从网上找图片,然后放到我写的app中,我点击图片按钮的时候,发现没变化,看了一下,原来没开网,同时遇到了线程的函数,我不会,只能上网找资料以及求助同学了,同时注意的是还要给网络连接权限以及空间权限才能下载图片。
+