-
Notifications
You must be signed in to change notification settings - Fork 0
/
Define SendFileTask.java
35 lines (27 loc) · 1.02 KB
/
Define SendFileTask.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
private class SendFileTask extends AsyncTask<String, Void, String> {
private String chatId;
private String botToken;
public SendFileTask(String chatId, String botToken) {
this.chatId = chatId;
this.botToken = botToken;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
Toast.makeText(MainActivity.this, "File is uploading...", Toast.LENGTH_SHORT).show();
}
@Override
protected String doInBackground(String... params) {
try {
String filePath = params[0];
return KoshurboiiTelegramBot.sendFileToTelegramBot(filePath, chatId, botToken);
}catch(Exception e){
e.printStackTrace();
return "File upload encountered an exception: " + e.getMessage();
}
}
@Override
protected void onPostExecute(String result) {
Toast.makeText(MainActivity.this, result, Toast.LENGTH_SHORT).show();
}
}