- 0
Achieving User Notification on Internet Access Denial in Code
-
Similar Content
-
- 17 replies
- 27,588 views
-
- 2 answers
- 1,310 views
-
- 0 replies
- 1,466 views
-
- 0 replies
- 1,833 views
-
- 1 comment
- 6,353 views
-
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Question
MahmoudBasem
In this code, when the user presses "Yes," it connects to the internet and downloads the file. However, when the user presses "No," it does not give an internet connection error. I want, when the user presses "No," to display a message informing them that the file is not allowed to connect to the internet to download the file and to open another file instead. How can I achieve this?
The code:
DownloadPath = gg.EXT_STORAGE .. "/Download/"
urls={'https://d.apkpure.com/b/APK/com.king.candycrushsaga?version=latest', 'https://d.apkpure.com/b/APK/com.google.android.gm?version=latest', 'https://d.apkpure.com/b/APK/com.alphainventor.filemanager?version=latest', 'https://d.apkpure.com/b/APK/com.facebook.lite?version=latest'}
names={'candy crush.apk','gmail.apk','file manager.apk','facebook lite.apk'}
Urls_name = {'كاندي كراش','جيميل','مدير ملفات','فبسبوك لايت'}
table.insert(Urls_name, 'رجوع')
selectedOption = #Urls_name -- رقم الموقع لاختيار "رجوع"
codes = gg.choice(Urls_name, nil)
if codes1==nil then -- القايمة المراد فتحها مرة اخري
end
if codes1 == selectedOption then
-- استدعاء الوظيفة للرجوع إلى القائمة السابقة
else
-- استمرار تنفيذ الخيار المحدد
local selectedUrl = urls[codes]
local selectedName = names[codes]
Time = os.clock()
getalldata = (gg.makeRequest(selectedUrl).content)
file = io.open(DownloadPath .. selectedName, "w")
file:write(getalldata)
io.close(file)
gg.toast("Dᴏᴡɴʟᴏᴀᴅ Sᴜᴄᴄᴇss")
gg.sleep(2500)
gg.toast("Dᴏᴡɴʟᴏᴀᴅ Pᴀᴛʜ :" .. DownloadPath)
gg.sleep(2500)
gg.toast("Fɪʟᴇ Dᴏᴡɴʟᴏᴀᴅ Tɪᴍᴇ :" .. string.format("%.2f", os.clock() - Time) .. " Sᴇᴄᴏɴᴅs")
gg.sleep(2500)
gg.alert(""..DownloadPath.."\n"..selectedName.."")
end
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now