I'm creating a bluetooth application and I'm trying to send a data to a private method from a public method but i got this error
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
the public method:
public void showTimeSet(long interval, Context context){
    if(interval !=0){
        Toast.makeText(context,"Countdown second is "+interval,Toast.LENGTH_LONG).show();
        String msg= String.valueOf(interval);
        try {
            sendMessage(msg);
        }catch (Exception e){
            Log.e(TAG, "showTimeSet Error sending message: "+e);
        }
    }
}
and the sendMessage method:
private void sendMessage(String message) {
    // Check that we're actually connected before trying anything
    if (mChatService.getState() != BluetoothService.STATE_CONNECTED) {
        Toast.makeText(getActivity(), R.string.not_connected, Toast.LENGTH_SHORT).show();
        return;
    }
    // Check that there's actually something to send
    if (message.length() > 0) {
        // Get the message bytes and tell the BluetoothService to write
        byte[] send = message.getBytes();
        mChatService.write(send);
        // Reset out string buffer to zero and clear the edit text field
        mOutStringBuffer.setLength(0);
        mOutEditText.setText(mOutStringBuffer);
    }
}
 
     
    