添加网络权限

This commit is contained in:
BA7LZD 2020-03-11 16:49:35 +08:00
parent d88443173f
commit ad6c29ea85
4 changed files with 15 additions and 5 deletions

View File

@ -20,9 +20,14 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yuxihan.sdu">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
@ -21,6 +22,7 @@
<activity android:name=".MainActivity">
</activity>
</application>
</manifest>

View File

@ -19,8 +19,10 @@ public class LoginDataSource {
public Result<LoggedInUser> login(final String username, String password) {
Retrofit retrofit = new Retrofit.Builder().baseUrl(Constant.BASE_URL)
.addConverterFactory(GsonConverterFactory.create()).build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constant.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
UpdateService updateService = retrofit.create(UpdateService.class);
Call<DataBean> call = updateService.login(username,password);
call.enqueue(new Callback<DataBean>() {
@ -34,6 +36,7 @@ public class LoginDataSource {
@Override
public void onFailure(Call<DataBean> call, Throwable t) {
//请求失败
Log.e("TAG","请求失败");
}
});

View File

@ -18,10 +18,10 @@
android:layout_marginStart="24dp"
android:layout_marginTop="96dp"
android:layout_marginEnd="24dp"
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:selectAllOnFocus="true"
android:text="admin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -33,12 +33,12 @@
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:hint="@string/prompt_password"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:selectAllOnFocus="true"
android:text="123456"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/username" />