class Download extends TimerTask
{
    public void run() {

        // do some computations that alter static variables
            String str = ; // something from the computations
        displayNotification(str);
    }

    private static final int NOTIFICATION_ID = 1;

    public void displayNotification(String msg)
    {
        NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new Notification(R.drawable.icon, msg, System.currentTimeMillis());

        // The PendingIntent will launch activity if the user selects this notification
        PendingIntent contentIntent = PendingIntent.getActivity(this, REQUEST_CODE, new Intent(this, ExpandNotification.class), 0);

        notification.setLatestEventInfo(this, "Title", "Details", contentIntent);
        // this line causes the trouble because "this" is not a context (i.e., Activity or Service)

        manager.notify(NOTIFICATION_ID, notification);
    }
}


Question: How can I launch a notification from the timer? Do I create an external Service class to do so?

Thanks so much. As a solo Android programmer, I am grateful for this community.


Question: No sound in Ubuntu except at log in
Answer: After searching, I have found a simple answer. Just execute 

killall pulseaudio


Your speakers should work fine now. To ensure this, test the sound stack in System Settings > Sound > Test Sound (Speaker test, Not Digital Output (S/PDIF) test)