-1

When I use this code here

Toast.makeText(HomeActivity.this, ""+accountKitError.getErrorType().getMessage());

I get a message Cannot resolve method 'makeText. This is my code:

@Override
public void onError(AccountKitError accountKitError) {
    Toast.makeText(HomeActivity.this, "+accountKitError.getErrorType().getMessage());
}
Zain
  • 37,492
  • 7
  • 60
  • 84
Jhumildes
  • 3
  • 1
  • Have you read the documentation of Toast.makeToast ? – Ezio Mar 06 '20 at 04:55
  • Does this answer your question? [How to display Toast in Android?](https://stackoverflow.com/questions/3500197/how-to-display-toast-in-android) – Ezio Mar 06 '20 at 04:57

1 Answers1

1

makeText method takes three parameters: the application context, the text message, and the duration for the toast. It returns a properly initialized Toast object. You can display the toast notification with show(), as shown in the following example:

Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;

Toast toast = Toast.makeText(context, text, duration);
toast.show();

In your case, you were missing the duration and the show(), add them like this and it will work:

Toast.makeText(
    HomeActivity.this, 
    ""+accountKitError.getErrorType().getMessage(),
    Toast.LENGTH_SHORT
).show();

Here is a link to the docs for more information about Toasts: https://developer.android.com/guide/topics/ui/notifiers/toasts#java