Reformat XashService.java
This commit is contained in:
parent
94ec3df282
commit
c658fe782d
1 changed files with 30 additions and 27 deletions
|
@ -34,18 +34,23 @@ import in.celest.xash3d.XashConfig;
|
||||||
import in.celest.xash3d.JoystickHandler;
|
import in.celest.xash3d.JoystickHandler;
|
||||||
|
|
||||||
|
|
||||||
public class XashService extends Service {
|
public class XashService extends Service
|
||||||
|
{
|
||||||
public static Notification notification;
|
public static Notification notification;
|
||||||
public static int status_image = R.id.status_image;
|
public static int status_image = R.id.status_image;
|
||||||
public static int status_text = R.id.status_text;
|
public static int status_text = R.id.status_text;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public static class exitButtonListener extends BroadcastReceiver {
|
|
||||||
|
public static class exitButtonListener extends BroadcastReceiver
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent)
|
||||||
|
{
|
||||||
XashActivity.mEngineReady = false;
|
XashActivity.mEngineReady = false;
|
||||||
XashActivity.nativeUnPause();
|
XashActivity.nativeUnPause();
|
||||||
XashActivity.nativeOnDestroy();
|
XashActivity.nativeOnDestroy();
|
||||||
|
@ -56,8 +61,8 @@ public class XashService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId)
|
||||||
|
{
|
||||||
int status_exit_button = R.id.status_exit_button;
|
int status_exit_button = R.id.status_exit_button;
|
||||||
int notify = R.layout.notify;
|
int notify = R.layout.notify;
|
||||||
if( XashActivity.sdk >= 21 )
|
if( XashActivity.sdk >= 21 )
|
||||||
|
@ -67,33 +72,32 @@ public class XashService extends Service {
|
||||||
status_exit_button = R.id.status_exit_button_21;
|
status_exit_button = R.id.status_exit_button_21;
|
||||||
notify = R.layout.notify_21;
|
notify = R.layout.notify_21;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("XashService", "Service Started");
|
Log.d("XashService", "Service Started");
|
||||||
Intent intent_ = new Intent(this, XashActivity.class);
|
|
||||||
intent_.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
Intent engineIntent = new Intent(this, XashActivity.class);
|
||||||
final PendingIntent pendingIntent = PendingIntent.getActivity(
|
engineIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
getApplicationContext(), 0, intent_, 0);
|
|
||||||
notification = new Notification(R.drawable.ic_launcher,
|
Intent exitIntent = new Intent(this, exitButtonListener.class);
|
||||||
"Xash3D", System.currentTimeMillis());
|
final PendingIntent pendingExitIntent = PendingIntent.getBroadcast(this, 0, exitIntent, 0);
|
||||||
|
|
||||||
notification.contentView = new RemoteViews(getApplicationContext()
|
notification = new Notification(R.drawable.ic_launcher, "Xash3D", System.currentTimeMillis());
|
||||||
.getPackageName(), notify);
|
|
||||||
notification.contentIntent = pendingIntent;
|
|
||||||
notification.flags = notification.flags
|
|
||||||
| Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE;
|
|
||||||
|
|
||||||
|
|
||||||
|
notification.contentView = new RemoteViews(getApplicationContext().getPackageName(), notify);
|
||||||
notification.contentView.setTextViewText(status_text, "Xash3D Engine");
|
notification.contentView.setTextViewText(status_text, "Xash3D Engine");
|
||||||
Intent exitIntent = new Intent(this, exitButtonListener.class);
|
|
||||||
PendingIntent pendingExitIntent = PendingIntent.getBroadcast(this, 0,
|
|
||||||
exitIntent, 0);
|
|
||||||
|
|
||||||
notification.contentView.setOnClickPendingIntent(status_exit_button, pendingExitIntent);
|
notification.contentView.setOnClickPendingIntent(status_exit_button, pendingExitIntent);
|
||||||
|
|
||||||
|
notification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, engineIntent, 0);
|
||||||
|
notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE;
|
||||||
|
|
||||||
startForeground(100, notification);
|
startForeground(100, notification);
|
||||||
|
|
||||||
return START_NOT_STICKY;
|
return START_NOT_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy()
|
||||||
|
{
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
Log.d("XashService", "Service Destroyed");
|
Log.d("XashService", "Service Destroyed");
|
||||||
}
|
}
|
||||||
|
@ -101,11 +105,11 @@ public class XashService extends Service {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate()
|
public void onCreate()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTaskRemoved(Intent rootIntent) {
|
public void onTaskRemoved(Intent rootIntent)
|
||||||
|
{
|
||||||
Log.e("XashService", "OnTaskRemoved");
|
Log.e("XashService", "OnTaskRemoved");
|
||||||
//if( XashActivity.mEngineReady )
|
//if( XashActivity.mEngineReady )
|
||||||
{
|
{
|
||||||
|
@ -118,5 +122,4 @@ public class XashService extends Service {
|
||||||
}
|
}
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue