From a1f3d3b56d41287973e7ac34affc599a45b37321 Mon Sep 17 00:00:00 2001
From: wufchun <1462803989@qq.com>
Date: Mon, 22 Apr 2019 20:56:52 +0800
Subject: [PATCH 1/4] =?UTF-8?q?#7=20#788=20=E7=AC=AC7=E6=AC=A1=E5=AE=9E?=
=?UTF-8?q?=E9=AA=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../app/src/main/AndroidManifest.xml | 8 +--
.../soft1714080902414/ConnectionNetwork.java | 52 +++++++++++++++++++
.../soft1714080902414/ResourceActivity.java | 11 ++--
...ty.java => Soft1714080902414Activity.java} | 2 +-
.../soft1714080902414/WordtestActivity.java | 2 +-
.../soft1714080902414/resourceActivity.java | 11 ++--
.../soft1714080902414/wordtestActivity.java | 2 +-
.../layout/soft_1714080902414_activity.xml | 2 +-
8 files changed, 76 insertions(+), 14 deletions(-)
create mode 100644 students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/ConnectionNetwork.java
rename students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/{Soft1714080902424Activity.java => Soft1714080902414Activity.java} (83%)
diff --git a/students/soft1714080902414/app/src/main/AndroidManifest.xml b/students/soft1714080902414/app/src/main/AndroidManifest.xml
index b20c64afd..520528e56 100644
--- a/students/soft1714080902414/app/src/main/AndroidManifest.xml
+++ b/students/soft1714080902414/app/src/main/AndroidManifest.xml
@@ -8,6 +8,7 @@
+
-
-
+
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/ConnectionNetwork.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/ConnectionNetwork.java
new file mode 100644
index 000000000..edd212e4d
--- /dev/null
+++ b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/ConnectionNetwork.java
@@ -0,0 +1,52 @@
+package edu.hzuapps.androidlabs.soft1714080902414;
+
+import android.app.AlertDialog;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+
+public class ConnectionNetwork {
+ //判断网络连接是否已开
+ public static boolean isConn(Context context) {
+ boolean bisConnFlag = false;
+ ConnectivityManager conManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo network = conManager.getActiveNetworkInfo();
+ if (network != null) {
+ bisConnFlag = conManager.getActiveNetworkInfo().isAvailable();
+ }
+ return bisConnFlag;
+ }
+ //打开网络设置界面
+ public static void setNetworkMethod(final Context context){
+ //提示对话框
+ AlertDialog.Builder builder=new AlertDialog.Builder(context);
+ builder.setTitle("网络设置提示").setMessage("网络连接不可用,是否进行设置?").setPositiveButton("设置", new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // TODO Auto-generated method stub
+ Intent intent=null;
+ //判断手机系统的版本 即API大于10 就是3.0或以上版本
+ if(android.os.Build.VERSION.SDK_INT>10){
+ intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
+ }else{
+ intent = new Intent();
+ ComponentName component = new ComponentName("com.android.settings","com.android.settings.WirelessSettings");
+ intent.setComponent(component);
+ intent.setAction("android.intent.action.VIEW");
+ }
+ context.startActivity(intent);
+ }
+ }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // TODO Auto-generated method stub
+ dialog.dismiss();
+ }
+ }).show();
+ }
+}
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/ResourceActivity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/ResourceActivity.java
index 7f7ea89a7..fa3de4281 100644
--- a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/ResourceActivity.java
+++ b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/ResourceActivity.java
@@ -13,12 +13,17 @@ public class ResourceActivity extends AppCompatActivity implements View.OnClickL
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_resource);
- button=(Button)findViewById(R.id.but);
+ button= findViewById(R.id.but);
button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
- Intent intent =new Intent(ResourceActivity.this, WordtestActivity.class);
- startActivity(intent);
+ if (!ConnectionNetwork.isConn(getApplicationContext())) {
+ ConnectionNetwork.setNetworkMethod(ResourceActivity.this);
+ }
+ else{Intent intent =new Intent(ResourceActivity.this, WordtestActivity.class);
+ startActivity(intent);}
+
}
+
}
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902424Activity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity.java
similarity index 83%
rename from students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902424Activity.java
rename to students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity.java
index c4e315984..afd8e67c0 100644
--- a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902424Activity.java
+++ b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity.java
@@ -3,7 +3,7 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
-public class Soft1714080902424Activity extends AppCompatActivity {
+public class Soft1714080902414Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/WordtestActivity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/WordtestActivity.java
index b662f2d35..8c2dfdfd2 100644
--- a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/WordtestActivity.java
+++ b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/WordtestActivity.java
@@ -31,7 +31,7 @@ public void onClick(View v) {
case R.id.button: Intent intent1 =new Intent(WordtestActivity.this, WordtestanswerActivity.class);
startActivity(intent1);break;
- case R.id.button1: Intent intent =new Intent(WordtestActivity.this,Soft1714080902424Activity.class);
+ case R.id.button1: Intent intent =new Intent(WordtestActivity.this, Soft1714080902414Activity.class);
startActivity(intent);break;
}
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/resourceActivity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/resourceActivity.java
index 7f7ea89a7..fa3de4281 100644
--- a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/resourceActivity.java
+++ b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/resourceActivity.java
@@ -13,12 +13,17 @@ public class ResourceActivity extends AppCompatActivity implements View.OnClickL
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_resource);
- button=(Button)findViewById(R.id.but);
+ button= findViewById(R.id.but);
button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
- Intent intent =new Intent(ResourceActivity.this, WordtestActivity.class);
- startActivity(intent);
+ if (!ConnectionNetwork.isConn(getApplicationContext())) {
+ ConnectionNetwork.setNetworkMethod(ResourceActivity.this);
+ }
+ else{Intent intent =new Intent(ResourceActivity.this, WordtestActivity.class);
+ startActivity(intent);}
+
}
+
}
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/wordtestActivity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/wordtestActivity.java
index b662f2d35..8c2dfdfd2 100644
--- a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/wordtestActivity.java
+++ b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/wordtestActivity.java
@@ -31,7 +31,7 @@ public void onClick(View v) {
case R.id.button: Intent intent1 =new Intent(WordtestActivity.this, WordtestanswerActivity.class);
startActivity(intent1);break;
- case R.id.button1: Intent intent =new Intent(WordtestActivity.this,Soft1714080902424Activity.class);
+ case R.id.button1: Intent intent =new Intent(WordtestActivity.this, Soft1714080902414Activity.class);
startActivity(intent);break;
}
diff --git a/students/soft1714080902414/app/src/main/res/layout/soft_1714080902414_activity.xml b/students/soft1714080902414/app/src/main/res/layout/soft_1714080902414_activity.xml
index 609df9108..7dcb81cee 100644
--- a/students/soft1714080902414/app/src/main/res/layout/soft_1714080902414_activity.xml
+++ b/students/soft1714080902414/app/src/main/res/layout/soft_1714080902414_activity.xml
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".Soft1714080902424Activity">
+ tools:context=".Soft1714080902414Activity">
Date: Mon, 22 Apr 2019 21:33:05 +0800
Subject: [PATCH 2/4] =?UTF-8?q?#7=20#788=20=E7=AC=AC7=E6=AC=A1=E5=AE=9E?=
=?UTF-8?q?=E9=AA=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../soft1714080902414/DatasaveActivity.java | 63 +++++++++++++++++++
.../WordtestanswerActivity.java | 13 ++++
2 files changed, 76 insertions(+)
create mode 100644 students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/DatasaveActivity.java
create mode 100644 students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/WordtestanswerActivity.java
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/DatasaveActivity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/DatasaveActivity.java
new file mode 100644
index 000000000..d00402c7f
--- /dev/null
+++ b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/DatasaveActivity.java
@@ -0,0 +1,63 @@
+package edu.hzuapps.androidlabs.soft1714080902414;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class DatasaveActivity extends AppCompatActivity implements View.OnClickListener {
+ private Button button1;
+ private Button button2;
+ private EditText editText1;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_datasave);
+ button1=(Button) findViewById(R.id.bt1);
+ button2=(Button) findViewById(R.id.bt2);
+ editText1=(EditText) findViewById(R.id.et1);
+ button1.setOnClickListener(this);
+ button2.setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId())
+ {
+ case R.id.bt1: String save=editText1.getText().toString().trim();
+ FileOutputStream fos;
+ try{
+ fos=openFileOutput("data.txt",MODE_PRIVATE);
+ fos.write(save.getBytes());
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ Toast.makeText( DatasaveActivity.this,"数据保存成功",Toast.LENGTH_SHORT).show();
+ break;
+ case R.id.bt2: String content="";
+ try {
+ FileInputStream fis=openFileInput("data.txt");
+ byte[] buffer=new byte[fis.available()];
+ fis.read(buffer);
+ content=new String(buffer);
+ fis.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ Toast.makeText(DatasaveActivity.this,"保存的数据为"+content,Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }
+}
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/WordtestanswerActivity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/WordtestanswerActivity.java
new file mode 100644
index 000000000..9aa0be483
--- /dev/null
+++ b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/WordtestanswerActivity.java
@@ -0,0 +1,13 @@
+package edu.hzuapps.androidlabs.soft1714080902414;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+
+public class WordtestanswerActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_wordtestanswer);
+ }
+}
From cf802febd1c7602ac4f8e74acbec1cb83819e33b Mon Sep 17 00:00:00 2001
From: wufchun <48343107+wufchun@users.noreply.github.com>
Date: Mon, 22 Apr 2019 21:34:22 +0800
Subject: [PATCH 3/4] Delete resourceActivity.java
---
.../soft1714080902414/resourceActivity.java | 29 -------------------
1 file changed, 29 deletions(-)
delete mode 100644 students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/resourceActivity.java
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/resourceActivity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/resourceActivity.java
deleted file mode 100644
index fa3de4281..000000000
--- a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/resourceActivity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package edu.hzuapps.androidlabs.soft1714080902414;
-
-import android.content.Intent;
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Button;
-
-public class ResourceActivity extends AppCompatActivity implements View.OnClickListener{
-
- private Button button;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_resource);
- button= findViewById(R.id.but);
- button.setOnClickListener(this);
- }
- @Override
- public void onClick(View v) {
- if (!ConnectionNetwork.isConn(getApplicationContext())) {
- ConnectionNetwork.setNetworkMethod(ResourceActivity.this);
- }
- else{Intent intent =new Intent(ResourceActivity.this, WordtestActivity.class);
- startActivity(intent);}
-
- }
-
- }
From 10f897d7b3e98c364f2f8a00f9d1ffd2e51f572a Mon Sep 17 00:00:00 2001
From: wufchun <48343107+wufchun@users.noreply.github.com>
Date: Mon, 22 Apr 2019 21:34:38 +0800
Subject: [PATCH 4/4] Delete wordtestActivity.java
---
.../soft1714080902414/wordtestActivity.java | 45 -------------------
1 file changed, 45 deletions(-)
delete mode 100644 students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/wordtestActivity.java
diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/wordtestActivity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/wordtestActivity.java
deleted file mode 100644
index 8c2dfdfd2..000000000
--- a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/wordtestActivity.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package edu.hzuapps.androidlabs.soft1714080902414;
-
-import android.content.Intent;
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Button;
-
-public class WordtestActivity extends AppCompatActivity {
-
- private Button button;
- private Button button1;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_wordtest);
- button=(Button)findViewById(R.id.button);
- button1=(Button)findViewById(R.id.button1);
- button.setOnClickListener(new MyButton());
- button1.setOnClickListener(new MyButton());
- }
-
- public class MyButton implements View.OnClickListener{
- @Override
- public void onClick(View v) {
-
-
- switch (v.getId())
- {
-
- case R.id.button: Intent intent1 =new Intent(WordtestActivity.this, WordtestanswerActivity.class);
- startActivity(intent1);break;
-
- case R.id.button1: Intent intent =new Intent(WordtestActivity.this, Soft1714080902414Activity.class);
- startActivity(intent);break;
- }
-
- }
- }
-
-
-
-
-
-}