forked from koying/SPMC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHG: [droid] Split backend (service) and frontend (app)
- Loading branch information
Showing
30 changed files
with
778 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package @APP_PACKAGE@; | ||
|
||
import android.app.Notification; | ||
import android.content.Intent; | ||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.os.IBinder; | ||
|
||
public class Service extends android.app.Service | ||
{ | ||
native boolean _launchApplication(); | ||
|
||
static private Boolean m_isStarted = false; | ||
public static Boolean isStarted() | ||
{ | ||
return m_isStarted; | ||
} | ||
|
||
public Service() | ||
{ | ||
} | ||
|
||
@Override | ||
public void onCreate() | ||
{ | ||
System.loadLibrary("@APP_NAME_LC@"); | ||
super.onCreate(); | ||
} | ||
|
||
@Override | ||
public int onStartCommand(Intent intent, int flags, int startId) | ||
{ | ||
if (!m_isStarted) | ||
m_isStarted =_launchApplication(); | ||
if (m_isStarted) | ||
{ | ||
Intent i = new Intent("@APP_PACKAGE@.SERVICE_STARTED"); | ||
sendBroadcast(i); | ||
} | ||
|
||
Bitmap icon = BitmapFactory.decodeResource(getResources(), | ||
R.drawable.ic_recommendation_80dp); | ||
|
||
Notification.Builder builder = new Notification.Builder(this) | ||
.setContentTitle(getString(R.string.app_name)) | ||
.setContentText("@APP_NAME@ is running...") | ||
.setSmallIcon(R.drawable.notif_icon) | ||
.setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false)) | ||
; | ||
|
||
Notification notification = builder.build(); | ||
startForeground(1, notification); | ||
return START_STICKY; | ||
} | ||
|
||
@Override | ||
public void onDestroy() | ||
{ | ||
Intent i = new Intent("@APP_PACKAGE@.SERVICE_STOPPED"); | ||
sendBroadcast(i); | ||
|
||
super.onDestroy(); | ||
} | ||
|
||
@Override | ||
public IBinder onBind(Intent intent) | ||
{ | ||
// TODO: Return the communication channel to the service. | ||
throw new UnsupportedOperationException("Not implemented"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.