Search in sources :

Example 1 with ServiceForegroundCompat

use of jackpal.androidterm.compat.ServiceForegroundCompat in project Android-Terminal-Emulator by jackpal.

the class TermService method onCreate.

@Override
public void onCreate() {
    // should really belong to the Application class, but we don't use one...
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    SharedPreferences.Editor editor = prefs.edit();
    String defValue = getDir("HOME", MODE_PRIVATE).getAbsolutePath();
    String homePath = prefs.getString("home_path", defValue);
    editor.putString("home_path", homePath);
    editor.commit();
    compat = new ServiceForegroundCompat(this);
    mTermSessions = new SessionList();
    /* Put the service in the foreground. */
    Notification notification = new Notification(R.drawable.ic_stat_service_notification_icon, getText(R.string.service_notify_text), System.currentTimeMillis());
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
    Intent notifyIntent = new Intent(this, Term.class);
    notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifyIntent, 0);
    notification.setLatestEventInfo(this, getText(R.string.application_terminal), getText(R.string.service_notify_text), pendingIntent);
    compat.startForeground(RUNNING_NOTIFICATION, notification);
    Log.d(TermDebug.LOG_TAG, "TermService started");
    return;
}
Also used : ServiceForegroundCompat(jackpal.androidterm.compat.ServiceForegroundCompat) SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) SessionList(jackpal.androidterm.util.SessionList) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Aggregations

Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 ServiceForegroundCompat (jackpal.androidterm.compat.ServiceForegroundCompat)1 SessionList (jackpal.androidterm.util.SessionList)1