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;
}
Aggregations