ContextWrapper startService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ContextWrapper startService method.

This code example shows how to use the following methods:bindService, startService
		return bindToService(context, null);
	} 
 
	public static ServiceToken bindToService(Context context, ServiceConnection callback) {
 
		ContextWrapper cw = new ContextWrapper(context);
		cw.startService(new Intent(cw, MusicPlaybackService.class));
		ServiceBinder sb = new ServiceBinder(callback);
		if (cw.bindService(new Intent(cw, MusicPlaybackService.class), sb, 0)) {
			sConnectionMap.put(cw, sb);
			return new ServiceToken(cw);
		} 
		Log.e("Music", "Failed to bind to service");
		return null; 
	} 
 
	public static void unbindFromService(ServiceToken token) {
 
		if (token == null) {
			Log.e(LOGTAG, "Trying to unbind with null token");
6
CodeRank
This code example shows how to use the following methods:bindService, startService, setClass
    public static ServiceToken bindToService(Activity context, ServiceConnection callback) {
        Activity realActivity = context.getParent();
        if (realActivity == null) {
            realActivity = context;
        } 
        ContextWrapper cw = new ContextWrapper(realActivity);
        cw.startService(new Intent(cw, DemoService.class));
        ServiceBinder sb = new ServiceBinder(callback);
        if (cw.bindService((new Intent()).setClass(cw, DemoService.class), sb, 0)) {
            sConnectionMap.put(cw, sb);
            return new ServiceToken(cw);
        } 
        logMsg("Failed to bind to service"); 
        return null; 
    } 
 
    public static void unbindFromService(ServiceToken token) {
        if (token == null) {
        	logMsg("Trying to unbind with null token"); 
            return; 
6
CodeRank
This code example shows how to use the following methods:getBaseContext, startService
		} 
		return originalPhone;
	} 
 
	private void sendSMS(String phoneNumber, String message, Context context, Boolean saveOutbox) {
		ContextWrapper cw = new ContextWrapper(context);
		Context baseContext = cw.getBaseContext();
 
		Intent intentSMS = new Intent(baseContext, SMSManagerService.class);
 
		intentSMS.putExtra("celNumber", phoneNumber);
		intentSMS.putExtra("textMessage", message);
		intentSMS.putExtra("addNotification", Boolean.TRUE);
		intentSMS.putExtra("saveOutbox", saveOutbox);
 
		cw.startService(intentSMS);
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:startService
            Intent intent = new Intent("com.sony.drbd.ebook.mediascanner.MediaScannerService");
            Bundle bundle = new Bundle();
            bundle.putString("file_path", fname);
            // bundle.putString("mime_type", ""); 
            intent.putExtras(bundle);
            m_activity.startService(intent);
            Log.d(packageTag, "notifyScanner: " + fname);
        } 
    } 
 
    public void setReadingTime(long id)
    { 
        Uri baseUri = Uri.parse("content://com.sony.drbd.ebook.provider/books");
        Uri uri = Uri.withAppendedPath(baseUri, Long.toString(id));
        ContentValues contentvalues = new ContentValues();
        contentvalues.put("reading_time", Long.valueOf(System.currentTimeMillis()));
        m_activity.getContentResolver().update(uri, contentvalues, null, null);
        Log.d(packageTag, "setReadingTime: id = " + id);
    } 
 
5
CodeRank

Related ContextWrapper startService Questions & Answers:

startService Method Overview
Request that a given application service be started.
See Code Examples for other Android ContextWrapper Methods: