root / src / com / rackspacecloud / android / ListAccountsActivity.java @ 54986b23
History | View | Annotate | Download (17 kB)
1 |
package com.rackspacecloud.android; |
---|---|
2 |
|
3 |
import java.io.FileInputStream; |
4 |
import java.io.FileNotFoundException; |
5 |
import java.io.FileOutputStream; |
6 |
import java.io.IOException; |
7 |
import java.io.ObjectInputStream; |
8 |
import java.io.ObjectOutputStream; |
9 |
import java.io.StreamCorruptedException; |
10 |
import java.util.ArrayList; |
11 |
import java.util.TreeMap; |
12 |
|
13 |
import com.rackspace.cloud.loadbalancer.api.client.Algorithm; |
14 |
import com.rackspace.cloud.loadbalancer.api.client.AlgorithmManager; |
15 |
import com.rackspace.cloud.loadbalancer.api.client.Protocol; |
16 |
import com.rackspace.cloud.loadbalancer.api.client.ProtocolManager; |
17 |
import com.rackspace.cloud.servers.api.client.Account; |
18 |
import com.rackspace.cloud.servers.api.client.Flavor; |
19 |
import com.rackspace.cloud.servers.api.client.FlavorManager; |
20 |
import com.rackspace.cloud.servers.api.client.Image; |
21 |
import com.rackspace.cloud.servers.api.client.ImageManager; |
22 |
import com.rackspace.cloud.servers.api.client.http.Authentication; |
23 |
|
24 |
import android.app.AlertDialog; |
25 |
import android.app.Dialog; |
26 |
import android.app.ListActivity; |
27 |
import android.app.ProgressDialog; |
28 |
import android.content.Context; |
29 |
import android.content.DialogInterface; |
30 |
import android.content.DialogInterface.OnCancelListener; |
31 |
import android.content.Intent; |
32 |
import android.os.AsyncTask; |
33 |
import android.os.Bundle; |
34 |
import android.util.Log; |
35 |
import android.view.ContextMenu; |
36 |
import android.view.ContextMenu.ContextMenuInfo; |
37 |
import android.view.LayoutInflater; |
38 |
import android.view.Menu; |
39 |
import android.view.MenuInflater; |
40 |
import android.view.MenuItem; |
41 |
import android.view.View; |
42 |
import android.view.View.OnClickListener; |
43 |
import android.view.ViewGroup; |
44 |
import android.widget.AdapterView.AdapterContextMenuInfo; |
45 |
import android.widget.ArrayAdapter; |
46 |
import android.widget.Button; |
47 |
import android.widget.EditText; |
48 |
import android.widget.ImageView; |
49 |
import android.widget.ListView; |
50 |
import android.widget.TextView; |
51 |
import android.widget.Toast; |
52 |
|
53 |
public class ListAccountsActivity extends ListActivity{ |
54 |
|
55 |
private final int PASSWORD_PROMPT = 123; |
56 |
private final String FILENAME = "accounts.data"; |
57 |
|
58 |
private boolean authenticating; |
59 |
private ArrayList<Account> accounts; |
60 |
private Intent tabViewIntent;
|
61 |
private ProgressDialog dialog;
|
62 |
private Context context; |
63 |
private AndroidCloudApplication app;
|
64 |
|
65 |
//need to store if the user has successfully logged in
|
66 |
private boolean loggedIn; |
67 |
|
68 |
|
69 |
public void onCreate(Bundle savedInstanceState) { |
70 |
super.onCreate(savedInstanceState);
|
71 |
onRestoreInstanceState(savedInstanceState); |
72 |
registerForContextMenu(getListView()); |
73 |
context = getApplicationContext(); |
74 |
tabViewIntent = new Intent(this, TabViewActivity.class); |
75 |
verifyPassword(); |
76 |
} |
77 |
|
78 |
@Override
|
79 |
protected void onSaveInstanceState(Bundle outState) { |
80 |
super.onSaveInstanceState(outState);
|
81 |
outState.putBoolean("authenticating", authenticating);
|
82 |
outState.putBoolean("loggedIn", loggedIn);
|
83 |
outState.putSerializable("accounts", accounts);
|
84 |
|
85 |
//need to set authenticating back to true because it is set to false
|
86 |
//in hideDialog()
|
87 |
if(authenticating){
|
88 |
hideDialog(); |
89 |
authenticating = true;
|
90 |
} |
91 |
writeAccounts(); |
92 |
} |
93 |
|
94 |
@SuppressWarnings("unchecked") |
95 |
@Override
|
96 |
protected void onRestoreInstanceState(Bundle state) { |
97 |
|
98 |
/*
|
99 |
* need reference to the app so you can access
|
100 |
* isLoggingIn
|
101 |
*/
|
102 |
app = (AndroidCloudApplication)this.getApplication();
|
103 |
|
104 |
if (state != null && state.containsKey("loggedIn")){ |
105 |
loggedIn = state.getBoolean("loggedIn");
|
106 |
} |
107 |
else{
|
108 |
loggedIn = false;
|
109 |
} |
110 |
|
111 |
if (state != null && state.containsKey("authenticating") && state.getBoolean("authenticating")) { |
112 |
showDialog(); |
113 |
} else {
|
114 |
hideDialog(); |
115 |
} |
116 |
if (state != null && state.containsKey("accounts")) { |
117 |
//accounts = readAccounts();
|
118 |
accounts = (ArrayList<Account>)state.getSerializable("accounts"); |
119 |
if (accounts.size() == 0) { |
120 |
displayNoAccountsCell(); |
121 |
} else {
|
122 |
getListView().setDividerHeight(1); // restore divider lines |
123 |
setListAdapter(new AccountAdapter());
|
124 |
} |
125 |
} else {
|
126 |
loadAccounts(); |
127 |
} |
128 |
} |
129 |
|
130 |
@Override
|
131 |
protected void onStart(){ |
132 |
super.onStart();
|
133 |
if(authenticating){
|
134 |
showDialog(); |
135 |
} |
136 |
} |
137 |
|
138 |
@Override
|
139 |
protected void onStop(){ |
140 |
super.onStop();
|
141 |
if(authenticating){
|
142 |
hideDialog(); |
143 |
authenticating = true;
|
144 |
} |
145 |
} |
146 |
|
147 |
|
148 |
/*
|
149 |
* if the application is password protected,
|
150 |
* the user must provide the password before
|
151 |
* gaining access
|
152 |
*/
|
153 |
private void verifyPassword(){ |
154 |
PasswordManager pwManager = new PasswordManager(getSharedPreferences(
|
155 |
Preferences.SHARED_PREFERENCES_NAME, MODE_PRIVATE));
|
156 |
if(pwManager.hasPassword() && !loggedIn){
|
157 |
createCustomDialog(PASSWORD_PROMPT); |
158 |
} |
159 |
} |
160 |
|
161 |
private boolean rightPassword(String password){ |
162 |
PasswordManager pwManager = new PasswordManager(getSharedPreferences(
|
163 |
Preferences.SHARED_PREFERENCES_NAME, MODE_PRIVATE));
|
164 |
return pwManager.verifyEnteredPassword(password);
|
165 |
} |
166 |
|
167 |
|
168 |
/*
|
169 |
* forces the user to enter a correct password
|
170 |
* before they gain access to application data
|
171 |
*/
|
172 |
private void createCustomDialog(int id) { |
173 |
final Dialog dialog = new Dialog(ListAccountsActivity.this); |
174 |
switch (id) {
|
175 |
case PASSWORD_PROMPT:
|
176 |
dialog.setContentView(R.layout.passworddialog); |
177 |
dialog.setTitle("Enter your password:");
|
178 |
dialog.setCancelable(false);
|
179 |
Button button = (Button) dialog.findViewById(R.id.submit_password); |
180 |
button.setOnClickListener(new OnClickListener() {
|
181 |
public void onClick(View v){ |
182 |
EditText passwordText = ((EditText)dialog.findViewById(R.id.submit_password_text)); |
183 |
if(!rightPassword(passwordText.getText().toString())){
|
184 |
passwordText.setText("");
|
185 |
showToast("Password was incorrect.");
|
186 |
loggedIn = false;
|
187 |
} |
188 |
else{
|
189 |
dialog.dismiss(); |
190 |
loggedIn = true;
|
191 |
} |
192 |
} |
193 |
|
194 |
}); |
195 |
dialog.show(); |
196 |
} |
197 |
} |
198 |
|
199 |
private void loadAccounts() { |
200 |
//check and see if there are any in memory
|
201 |
if(accounts == null){ |
202 |
accounts = readAccounts(); |
203 |
} |
204 |
//if nothing was written before accounts will still be null
|
205 |
if(accounts == null){ |
206 |
accounts = new ArrayList<Account>(); |
207 |
} |
208 |
|
209 |
setAccountList(); |
210 |
} |
211 |
|
212 |
private void setAccountList() { |
213 |
|
214 |
if (accounts.size() == 0) { |
215 |
displayNoAccountsCell(); |
216 |
} else {
|
217 |
getListView().setDividerHeight(1); // restore divider lines |
218 |
this.setListAdapter(new AccountAdapter()); |
219 |
} |
220 |
} |
221 |
|
222 |
private void writeAccounts(){ |
223 |
FileOutputStream fos;
|
224 |
ObjectOutputStream out = null; |
225 |
try{
|
226 |
fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
|
227 |
out = new ObjectOutputStream(fos); |
228 |
out.writeObject(accounts); |
229 |
out.flush(); |
230 |
out.close(); |
231 |
} catch (FileNotFoundException e) { |
232 |
showAlert("Error", "Could not save accounts."); |
233 |
e.printStackTrace(); |
234 |
} catch (IOException e) { |
235 |
showAlert("Error", "Could not save accounts."); |
236 |
e.printStackTrace(); |
237 |
} |
238 |
} |
239 |
|
240 |
private ArrayList<Account> readAccounts(){ |
241 |
FileInputStream fis;
|
242 |
ObjectInputStream in;
|
243 |
try {
|
244 |
fis = openFileInput(FILENAME); |
245 |
in = new ObjectInputStream(fis); |
246 |
@SuppressWarnings("unchecked") |
247 |
ArrayList<Account> file = (ArrayList<Account>)in.readObject(); |
248 |
in.close(); |
249 |
return file;
|
250 |
} catch (FileNotFoundException e) { |
251 |
//showAlert("Error", "Could not load accounts.");
|
252 |
e.printStackTrace(); |
253 |
return null; |
254 |
} catch (StreamCorruptedException e) { |
255 |
showAlert("Error", "Could not load accounts."); |
256 |
e.printStackTrace(); |
257 |
} catch (IOException e) { |
258 |
showAlert("Error", "Could not load accounts."); |
259 |
e.printStackTrace(); |
260 |
} catch (ClassNotFoundException e) { |
261 |
showAlert("Error", "Could not load accounts."); |
262 |
e.printStackTrace(); |
263 |
} |
264 |
return null; |
265 |
|
266 |
} |
267 |
|
268 |
private void displayNoAccountsCell() { |
269 |
String a[] = new String[1]; |
270 |
a[0] = "No Accounts"; |
271 |
setListAdapter(new ArrayAdapter<String>(getApplicationContext(), R.layout.noaccountscell, R.id.no_accounts_label, a)); |
272 |
getListView().setTextFilterEnabled(true);
|
273 |
getListView().setDividerHeight(0); // hide the dividers so it won't look like a list row |
274 |
getListView().setItemsCanFocus(false);
|
275 |
} |
276 |
|
277 |
protected void onListItemClick(ListView l, View v, int position, long id) { |
278 |
if (accounts != null && accounts.size() > 0) { |
279 |
//setActivityIndicatorsVisibility(View.VISIBLE, v);
|
280 |
Account.setAccount(accounts.get(position)); |
281 |
login(); |
282 |
} |
283 |
} |
284 |
|
285 |
public void login() { |
286 |
//showActivityIndicators();
|
287 |
//setLoginPreferences();
|
288 |
new AuthenticateTask().execute((Void[]) null); |
289 |
} |
290 |
|
291 |
//setup menu for when menu button is pressed
|
292 |
public boolean onCreateOptionsMenu(Menu menu) { |
293 |
super.onCreateOptionsMenu(menu);
|
294 |
MenuInflater inflater = getMenuInflater(); |
295 |
inflater.inflate(R.menu.accounts_list_menu, menu); |
296 |
return true; |
297 |
} |
298 |
|
299 |
@Override
|
300 |
//in options menu, when add account is selected go to add account activity
|
301 |
public boolean onOptionsItemSelected(MenuItem item) { |
302 |
switch (item.getItemId()) {
|
303 |
case R.id.add_account:
|
304 |
startActivityForResult(new Intent(this, AddAccountActivity.class), 78); // arbitrary number; never used again |
305 |
return true; |
306 |
|
307 |
case R.id.contact_rackspace:
|
308 |
startActivity(new Intent(this, ContactActivity.class)); |
309 |
return true; |
310 |
|
311 |
case R.id.add_password:
|
312 |
startActivity(new Intent(this, CreatePasswordActivity.class)); |
313 |
return true; |
314 |
} |
315 |
return false; |
316 |
} |
317 |
|
318 |
//the context menu for a long press on an account
|
319 |
public void onCreateContextMenu(ContextMenu menu, View v, |
320 |
ContextMenuInfo menuInfo) { |
321 |
super.onCreateContextMenu(menu, v, menuInfo);
|
322 |
MenuInflater inflater = getMenuInflater(); |
323 |
inflater.inflate(R.menu.account_context_menu, menu); |
324 |
} |
325 |
|
326 |
//removes the selected account from account list if remove is clicked
|
327 |
public boolean onContextItemSelected(MenuItem item) { |
328 |
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); |
329 |
accounts.remove(info.position); |
330 |
writeAccounts(); |
331 |
loadAccounts(); |
332 |
return true; |
333 |
} |
334 |
|
335 |
class AccountAdapter extends ArrayAdapter<Account> { |
336 |
|
337 |
AccountAdapter() { |
338 |
super(ListAccountsActivity.this, R.layout.listaccountcell, accounts);
|
339 |
} |
340 |
|
341 |
public View getView(int position, View convertView, ViewGroup parent) { |
342 |
|
343 |
LayoutInflater inflater = getLayoutInflater(); |
344 |
View row = inflater.inflate(R.layout.listaccountcell, parent, false); |
345 |
|
346 |
TextView label = (TextView) row.findViewById(R.id.label); |
347 |
label.setText(accounts.get(position).getUsername()); |
348 |
|
349 |
TextView sublabel = (TextView) row.findViewById(R.id.sublabel); |
350 |
sublabel.setText(getAccountServer(accounts.get(position))); |
351 |
|
352 |
ImageView icon = (ImageView) row.findViewById(R.id.account_type_icon); |
353 |
icon.setImageResource(setAccountIcon(accounts.get(position))); |
354 |
|
355 |
return row;
|
356 |
} |
357 |
} |
358 |
|
359 |
public String getAccountServer(Account account){ |
360 |
String authServer = account.getAuthServer();
|
361 |
String result;
|
362 |
if(authServer.equals(Preferences.COUNTRY_UK_AUTH_SERVER)){ |
363 |
result = "Rackspace Cloud (UK)";
|
364 |
} |
365 |
else if(authServer.equals(Preferences.COUNTRY_US_AUTH_SERVER)){ |
366 |
result = "Rackspace Cloud (US)";
|
367 |
} |
368 |
else{
|
369 |
result = "Custom";
|
370 |
//setCustomIcon();
|
371 |
} |
372 |
return result;
|
373 |
} |
374 |
|
375 |
//display rackspace logo for cloud accounts and openstack logo for others
|
376 |
private int setAccountIcon(Account account){ |
377 |
if(account.getAuthServer().equals(Preferences.COUNTRY_UK_AUTH_SERVER) |
378 |
|| account.getAuthServer().equals(Preferences.COUNTRY_US_AUTH_SERVER)){
|
379 |
return R.drawable.rackspacecloud_icon;
|
380 |
} |
381 |
else{
|
382 |
return R.drawable.openstack_icon;
|
383 |
} |
384 |
} |
385 |
|
386 |
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
387 |
super.onActivityResult(requestCode, resultCode, data);
|
388 |
|
389 |
if(requestCode == 187){ |
390 |
hideDialog(); |
391 |
} |
392 |
|
393 |
if (resultCode == RESULT_OK && requestCode == 78) { |
394 |
Account acc = new Account();
|
395 |
Bundle b = data.getBundleExtra("accountInfo");
|
396 |
acc.setApiKey(b.getString("apiKey"));
|
397 |
acc.setUsername(b.getString("username"));
|
398 |
acc.setAuthServer(b.getString("server"));
|
399 |
accounts.add(acc); |
400 |
writeAccounts(); |
401 |
loadAccounts(); |
402 |
} |
403 |
} |
404 |
/*
|
405 |
private void setActivityIndicatorsVisibility(int visibility) {
|
406 |
//FINISH THIS TO LET USER KNOW PROGRAM IS STILL WORKING
|
407 |
|
408 |
//ProgressBar pb = new ProgressBar();
|
409 |
//TextView tv = (TextView) findViewById(R.id.login_authenticating_label);
|
410 |
//pb.setVisibility(visibility);
|
411 |
//tv.setVisibility(visibility);
|
412 |
}
|
413 |
|
414 |
private void setActivityIndicatorsVisibility(int visibility, View v) {
|
415 |
//FINISH THIS TO LET USER KNOW PROGRAM IS STILL WORKING
|
416 |
|
417 |
//ProgressBar pb = new ProgressBar();
|
418 |
//TextView tv = (TextView) findViewById(R.id.login_authenticating_label);
|
419 |
//pb.setVisibility(visibility);
|
420 |
//tv.setVisibility(visibility);
|
421 |
}
|
422 |
*/
|
423 |
|
424 |
private void showDialog() { |
425 |
app.setIsLoggingIn(true);
|
426 |
authenticating = true;
|
427 |
if(dialog == null || !dialog.isShowing()){ |
428 |
dialog = ProgressDialog.show(ListAccountsActivity.this, "", "Authenticating...", true); |
429 |
dialog.setCancelable(true);
|
430 |
dialog.setOnCancelListener(new OnCancelListener() {
|
431 |
|
432 |
@Override
|
433 |
public void onCancel(DialogInterface dialog) { |
434 |
app.setIsLoggingIn(false);
|
435 |
hideDialog(); |
436 |
} |
437 |
}); |
438 |
} |
439 |
} |
440 |
|
441 |
private void hideDialog() { |
442 |
if(dialog != null){ |
443 |
dialog.dismiss(); |
444 |
} |
445 |
authenticating = false;
|
446 |
} |
447 |
|
448 |
private class AuthenticateTask extends AsyncTask<Void, Void, Boolean> { |
449 |
|
450 |
@Override
|
451 |
protected void onPreExecute(){ |
452 |
Log.d("info", "AuthenticateTask Started"); |
453 |
showDialog(); |
454 |
} |
455 |
|
456 |
@Override
|
457 |
protected Boolean doInBackground(Void... arg0) { |
458 |
return new Boolean(Authentication.authenticate(context)); |
459 |
} |
460 |
|
461 |
@Override
|
462 |
protected void onPostExecute(Boolean result) { |
463 |
if (result.booleanValue()) {
|
464 |
//startActivity(tabViewIntent);
|
465 |
if(app.isLogginIn()){
|
466 |
new LoadImagesTask().execute((Void[]) null); |
467 |
} else {
|
468 |
hideDialog(); |
469 |
} |
470 |
} else {
|
471 |
hideDialog(); |
472 |
showAlert("Login Failure", "Authentication failed. Please check your User Name and API Key."); |
473 |
} |
474 |
} |
475 |
} |
476 |
|
477 |
private class LoadImagesTask extends AsyncTask<Void, Void, ArrayList<Image>> { |
478 |
|
479 |
@Override
|
480 |
protected ArrayList<Image> doInBackground(Void... arg0) { |
481 |
Log.d("info", "LoadImagesTask Started"); |
482 |
return (new ImageManager()).createList(true, context); |
483 |
} |
484 |
|
485 |
@Override
|
486 |
protected void onPostExecute(ArrayList<Image> result) { |
487 |
if (result != null && result.size() > 0) { |
488 |
TreeMap<String, Image> imageMap = new TreeMap<String, Image>(); |
489 |
for (int i = 0; i < result.size(); i++) { |
490 |
Image image = result.get(i);
|
491 |
imageMap.put(image.getId(), image); |
492 |
} |
493 |
Image.setImages(imageMap);
|
494 |
if(app.isLogginIn()){
|
495 |
new LoadProtocolsTask().execute((Void[]) null); |
496 |
} else {
|
497 |
hideDialog(); |
498 |
} |
499 |
} else {
|
500 |
hideDialog(); |
501 |
showAlert("Login Failure", "There was a problem loading server images. Please try again."); |
502 |
} |
503 |
} |
504 |
} |
505 |
|
506 |
private class LoadProtocolsTask extends AsyncTask<Void, Void, ArrayList<Protocol>> { |
507 |
|
508 |
@Override
|
509 |
protected ArrayList<Protocol> doInBackground(Void... arg0) { |
510 |
Log.d("info", "LoadProtocolsTask Started"); |
511 |
return (new ProtocolManager()).createList(context); |
512 |
} |
513 |
|
514 |
@Override
|
515 |
protected void onPostExecute(ArrayList<Protocol> result) { |
516 |
if (result != null && result.size() > 0) { |
517 |
Protocol.setProtocols(result); |
518 |
if(app.isLogginIn()){
|
519 |
new LoadAlgorithmsTask().execute((Void[]) null); |
520 |
} else {
|
521 |
hideDialog(); |
522 |
} |
523 |
} else {
|
524 |
hideDialog(); |
525 |
showAlert("Login Failure", "There was a problem loading load balancer protocols. Please try again."); |
526 |
} |
527 |
} |
528 |
} |
529 |
|
530 |
private class LoadAlgorithmsTask extends AsyncTask<Void, Void, ArrayList<Algorithm>> { |
531 |
|
532 |
@Override
|
533 |
protected ArrayList<Algorithm> doInBackground(Void... arg0) { |
534 |
Log.d("info", "LoadAlgorithmsTask Started"); |
535 |
return (new AlgorithmManager()).createList(context); |
536 |
} |
537 |
|
538 |
@Override
|
539 |
protected void onPostExecute(ArrayList<Algorithm> result) { |
540 |
if (result != null && result.size() > 0) { |
541 |
Algorithm.setAlgorithms(result); |
542 |
if(app.isLogginIn()){
|
543 |
new LoadFlavorsTask().execute((Void[]) null); |
544 |
} else {
|
545 |
hideDialog(); |
546 |
} |
547 |
} else {
|
548 |
hideDialog(); |
549 |
showAlert("Login Failure", "There was a problem loading load balancer algorithms. Please try again."); |
550 |
} |
551 |
} |
552 |
} |
553 |
|
554 |
private class LoadFlavorsTask extends AsyncTask<Void, Void, ArrayList<Flavor>> { |
555 |
|
556 |
@Override
|
557 |
protected ArrayList<Flavor> doInBackground(Void... arg0) { |
558 |
Log.d("info", "LoadFlavorsTask Started"); |
559 |
return (new FlavorManager()).createList(true, context); |
560 |
} |
561 |
|
562 |
@Override
|
563 |
protected void onPostExecute(ArrayList<Flavor> result) { |
564 |
if (result != null && result.size() > 0) { |
565 |
TreeMap<String, Flavor> flavorMap = new TreeMap<String, Flavor>(); |
566 |
for (int i = 0; i < result.size(); i++) { |
567 |
Flavor flavor = result.get(i); |
568 |
flavorMap.put(flavor.getId(), flavor); |
569 |
} |
570 |
Flavor.setFlavors(flavorMap); |
571 |
hideDialog(); |
572 |
Log.d("info", "Starting TabViewIntent"); |
573 |
if(app.isLogginIn()){
|
574 |
startActivityForResult(tabViewIntent, 187);
|
575 |
} else {
|
576 |
hideDialog(); |
577 |
} |
578 |
} else {
|
579 |
hideDialog(); |
580 |
showAlert("Login Failure", "There was a problem loading server flavors. Please try again."); |
581 |
} |
582 |
} |
583 |
} |
584 |
|
585 |
private void showAlert(String title, String message) { |
586 |
AlertDialog alert = new AlertDialog.Builder(this).create(); |
587 |
alert.setTitle(title); |
588 |
alert.setMessage(message); |
589 |
alert.setButton("OK", new DialogInterface.OnClickListener() { |
590 |
public void onClick(DialogInterface dialog, int which) { |
591 |
return;
|
592 |
} }); |
593 |
alert.show(); |
594 |
} |
595 |
|
596 |
private void showToast(String message) { |
597 |
Context context = getApplicationContext();
|
598 |
int duration = Toast.LENGTH_SHORT;
|
599 |
Toast toast = Toast.makeText(context, message, duration); |
600 |
toast.show(); |
601 |
} |
602 |
|
603 |
|
604 |
|
605 |
|
606 |
} |