Skip to content

Instantly share code, notes, and snippets.

@nipundavid
Created July 8, 2017 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nipundavid/7cc4d4ea7e177cecfe127b5cd4d4ed92 to your computer and use it in GitHub Desktop.
Save nipundavid/7cc4d4ea7e177cecfe127b5cd4d4ed92 to your computer and use it in GitHub Desktop.
Singleto class to call toast
package com.plugin.android.unityplugin;
import android.content.Context;
import android.widget.Toast;
/**
* Created by nipundavid on 6/19/2017.
*/
public class PluginClass {
private Context context;
private static PluginClass instance;
public PluginClass() {
this.instance = this;
}
public static PluginClass instance() {
if(instance == null) {
instance = new PluginClass();
}
return instance;
}
public void setContext(Context context) {
this.context = context;
}
public void showMessage(String message) {
Toast.makeText(this.context, message, Toast.LENGTH_SHORT).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment