Skip to content

Commit 2ca533d

Browse files
committed
關於頁面跳轉github頁面錯誤修正
1 parent 4c728be commit 2ca533d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

app/src/main/java/com/jimmyworks/easyhttpexample/activity/AboutActivity.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.jimmyworks.easyhttpexample.activity
22

3+
import android.content.ActivityNotFoundException
34
import android.content.Intent
45
import android.net.Uri
56
import android.os.Bundle
67
import android.view.View
78
import androidx.appcompat.app.AppCompatActivity
9+
import com.jimmyworks.easyhttpexample.R
810
import com.jimmyworks.easyhttpexample.databinding.ActivityAboutBinding
11+
import com.jimmyworks.easyhttpexample.utils.UiUtils
912

1013

1114
class AboutActivity : AppCompatActivity(), View.OnClickListener {
@@ -25,9 +28,16 @@ class AboutActivity : AppCompatActivity(), View.OnClickListener {
2528
finish()
2629
}
2730
binding.ivGithub.id -> {
28-
val intent = Intent(Intent.ACTION_VIEW)
29-
intent.data = Uri.parse("https://github.com/af19git5/AndroidEasyHttp")
30-
startActivity(intent)
31+
try {
32+
startActivity(
33+
Intent(
34+
Intent.ACTION_VIEW,
35+
Uri.parse("https://github.com/af19git5/AndroidEasyHttp")
36+
)
37+
)
38+
} catch (e: ActivityNotFoundException) {
39+
UiUtils.toast(this, getString(R.string.open_github_error))
40+
}
3141
}
3242
}
3343
}

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232
<string name="text">Text</string>
3333
<string name="about_content">This app is demo for EasyHttp Library.\nYou can get more information in the github page.</string>
3434
<string name="url_error_hint">Url Error</string>
35+
<string name="open_github_error">Open github error</string>
3536
</resources>

0 commit comments

Comments
 (0)