@@ -64,22 +64,25 @@ public int onStartCommand(Intent intent, int flags, int startId) {
6464 pythonThread = new Thread (this );
6565 pythonThread .start ();
6666
67- if (this .canDisplayNotification ()) {
67+ doStartForeground (extras );
68+
69+ return START_NOT_STICKY ;
70+ }
71+
72+ protected void doStartForeground (Bundle extras ) {
73+ if (canDisplayNotification ()) {
6874 String serviceTitle = extras .getString ("serviceTitle" );
6975 String serviceDescription = extras .getString ("serviceDescription" );
7076
7177 Context context = getApplicationContext ();
7278 Notification notification = new Notification (context .getApplicationInfo ().icon ,
73- serviceTitle ,
74- System .currentTimeMillis ());
79+ serviceTitle , System .currentTimeMillis ());
7580 Intent contextIntent = new Intent (context , PythonActivity .class );
7681 PendingIntent pIntent = PendingIntent .getActivity (context , 0 , contextIntent ,
77- PendingIntent .FLAG_UPDATE_CURRENT );
82+ PendingIntent .FLAG_UPDATE_CURRENT );
7883 notification .setLatestEventInfo (context , serviceTitle , serviceDescription , pIntent );
7984 startForeground (1 , notification );
8085 }
81-
82- return START_NOT_STICKY ;
8386 }
8487
8588 @ Override
@@ -91,7 +94,7 @@ public void onDestroy() {
9194
9295 @ Override
9396 public void run (){
94- PythonUtil .loadLibraries (getFilesDir ());
97+ PythonUtil .loadLibraries (getFilesDir ());
9598 this .mService = this ;
9699 nativeStart (
97100 androidPrivate , androidArgument ,
0 commit comments