Skip to content

Commit

Permalink
Merge pull request #1573 from wufchun/master
Browse files Browse the repository at this point in the history
#7 #788 第七次实验
  • Loading branch information
zengsn authored Apr 23, 2019
2 parents 3958ac0 + 10f897d commit 1f8c959
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 10 deletions.
8 changes: 4 additions & 4 deletions students/soft1714080902414/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".FileDownloaderActivity" android:exported="true"></activity>

<activity android:name=".Soft1714080902414Activity"></activity>
<activity
android:name=".ResourceActivity"
android:name=".FileDownloaderActivity"
android:exported="true" />
<activity
android:name=".WordtestanswerActivity"
Expand All @@ -30,7 +30,7 @@
android:name=".DatasaveActivity"
android:exported="true" />
<activity
android:name=".Soft1714080902424Activity"
android:name=".ResourceActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<TextView
android:layout_width="wrap_content"
Expand Down

0 comments on commit 1f8c959

Please sign in to comment.