Android Service - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Service class.

This code example shows how to use the following methods: getSystemService, getClass
        invokeMethod(service, mSetForeground, Boolean.FALSE);
    } 
 
    public ServiceForegroundCompat(Service service) {
        this.service = service;
        mNM = (NotificationManager)service.getSystemService(Context.NOTIFICATION_SERVICE);
 
        Class<?> clazz = service.getClass();
 
        try { 
            mStartForeground = clazz.getMethod("startForeground", mStartForegroundSig);
            mStopForeground = clazz.getMethod("stopForeground", mStopForegroundSig);
        } catch (NoSuchMethodException e) {
            mStartForeground = mStopForeground = null;
        } 
 
        try { 
            mSetForeground = clazz.getMethod("setForeground", mSetForegroundSig);
        } catch (NoSuchMethodException e) {
            mSetForeground = null;
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getSystemService, getClass
        mSetForegroundArgs[0] = Boolean.FALSE;
        invokeMethod(mSetForeground, mSetForegroundArgs);
    } 
 
    public void init() { 
        mNM = (NotificationManager) mService.getSystemService(Service.NOTIFICATION_SERVICE);
        try { 
            mStartForeground = mService.getClass().getMethod("startForeground",
                    mStartForegroundSignature);
            mStopForeground = mService.getClass().getMethod("stopForeground",
                    mStopForegroundSignature);
            return; 
        } catch (NoSuchMethodException e) {
            // Running on an older platform. 
            mStartForeground = mStopForeground = null;
        } 
        try { 
            mSetForeground = mService.getClass()
                    .getMethod("setForeground", mSetForegroundSignature);
        } catch (NoSuchMethodException e) {

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getSystemService, getClass
        invokeMethod(service, mSetForeground, Boolean.FALSE);
    } 
 
    public ServiceForegroundCompat(Service service) {
        this.service = service;
        mNM = (NotificationManager)service.getSystemService(Context.NOTIFICATION_SERVICE);
 
        Class<?> clazz = service.getClass();
 
        try { 
            mStartForeground = clazz.getMethod("startForeground", mStartForegroundSig);
            mStopForeground = clazz.getMethod("stopForeground", mStopForegroundSig);
        } catch (NoSuchMethodException e) {
            mStartForeground = mStopForeground = null;
        } 
 
        try { 
            mSetForeground = clazz.getMethod("setForeground", mSetForegroundSig);
        } catch (NoSuchMethodException e) {
            mSetForeground = null;
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: stopForeground
class StopForegroundWrapper 
{ 
	public void stopForegroundAndRemoveNotificationIcon(Service service)
	{ 
		// The true argument removes the notification icon. 
		service.stopForeground(true);
	} 
} 
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setForeground
			private static final PreEclair sInstance = new PreEclair();
		} 
 
		@Override 
		public void showRunningNotification(Service context) {
			context.setForeground(true);
			getNotificationManager(context).notify(ONLINE_NOTIFICATION, newRunningNotification(context));
		} 
 
		@Override 
		public void hideRunningNotification(Service context) {
			context.setForeground(false);
			getNotificationManager(context).cancel(ONLINE_NOTIFICATION);
		} 
	} 
 
	private static class EclairAndBeyond extends ConnectionNotifier { 
		private static class Holder { 
			private static final EclairAndBeyond sInstance = new EclairAndBeyond();
		} 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android Service Questions & Answers:

Other Android Service Examples

13:	import android.util.Log;
14:	
15:	public class GPSTracker extends Service implements LocationListener {
16:	
17:		private final Context mContext;

Read More

13:	import android.util.Log;
14:	
15:	public class GPSTracker extends Service implements LocationListener {
16:	
17:		private final Context mContext;

Read More

See Code Examples for Android Service Methods: