I'm working in Android Studio 3.0.1. I created a EditText in which I write a text now I want when user long press that text it get copied in clipboard.
I used a method here (which is not working)
ClipboardManager mClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
mEditText.setText(mClipboard.getText());
It says Method Invocation 'get text' may produce 'java.lang.NullpoinyerException' I need help what should i do ?