当前位置: 首页>>代码示例>>Java>>正文


Java WakefulBroadcastReceiver.completeWakefulIntent方法代码示例

本文整理汇总了Java中android.support.v4.content.WakefulBroadcastReceiver.completeWakefulIntent方法的典型用法代码示例。如果您正苦于以下问题:Java WakefulBroadcastReceiver.completeWakefulIntent方法的具体用法?Java WakefulBroadcastReceiver.completeWakefulIntent怎么用?Java WakefulBroadcastReceiver.completeWakefulIntent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.content.WakefulBroadcastReceiver的用法示例。


在下文中一共展示了WakefulBroadcastReceiver.completeWakefulIntent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onHandleIntent

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    if (intent.getExtras() != null) {
        String personId = intent.getStringExtra("person_id");
        Realm realm = Realm.getDefaultInstance();
        Person person = realm.where(Person.class).equalTo("id", personId).findFirst();
        final String output = person.toString();
        new Handler(getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(getApplicationContext(), "Loaded Person from broadcast-receiver->intent-service: " + output, Toast.LENGTH_LONG).show();
            }
        });
        realm.close();
    }

    // All the work is done, release the wake locks/etc
    WakefulBroadcastReceiver.completeWakefulIntent(intent);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:WakefulReceivingService.java

示例2: onHandleIntent

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(@Nullable Intent intent) {
    if(intent == null) return;
    try {
        final String action = intent.getAction();
        if(ACTION_CHECK.equals(action)) {
            loadNotifications();
        } else if(ACTION_DELETE.equals(action) && intent.hasExtra("notification")) {
            Editor.getEditor(this).markNotificationThreadRead(
                    ((Notification) intent.getParcelableExtra("notification")).getId()
            );
        }
    } finally {
        Logger.i(TAG, "onHandleIntent: " + intent.toString());
        WakefulBroadcastReceiver.completeWakefulIntent(intent);
    }
}
 
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:18,代码来源:NotificationIntentService.java

示例3: onStartCommand

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    LOGD(TAG, "onStartCommand: " + (intent != null ? intent.toString() : "no intent"));
    enforceCallingPermission(DashClockExtension.PERMISSION_READ_EXTENSION_DATA);

    if (intent != null) {
        String action = intent.getAction();
        if (ACTION_UPDATE_WIDGETS.equals(action)) {
            handleUpdateWidgets(intent);

        } else if (ACTION_UPDATE_EXTENSIONS.equals(action)) {
            handleUpdateExtensions(intent);
        }

        // If started by a wakeful broadcast receiver, release the wake lock it acquired.
        WakefulBroadcastReceiver.completeWakefulIntent(intent);
    }

    return START_STICKY;
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:21,代码来源:DashClockService.java

示例4: onHandleIntent

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    Log.d(getClass().getSimpleName(), "onHandleIntent, started handling a notification event");
    try {
        String action = intent.getAction();
        if (ACTION_START.equals(action)) {
            Contact contact = intent.getParcelableExtra(EXTRA_CONTACT_NOTIFICATION);
            //TODO processStartNotification(contact);
        }
        if (ACTION_DELETE.equals(action)) {
            processDeleteNotification(intent);
        }
    } finally {
        WakefulBroadcastReceiver.completeWakefulIntent(intent);
    }
}
 
开发者ID:Kunzisoft,项目名称:RememBirthday,代码行数:17,代码来源:NotificationIntentService.java

示例5: onHandleIntent

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
	Bundle extras = intent.getExtras();
	GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
	String messageType = gcm.getMessageType(intent);

	if (!extras.isEmpty()) { // has effect of unparcelling Bundle
		if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
				.equals(messageType)) {
		} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
				.equals(messageType)) {
		} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
				.equals(messageType)) {
			if (MyApp.getInstance().isPushEnabled()) {
				sendNotification("Received: " + extras.toString());
			}
		}
	}
	WakefulBroadcastReceiver.completeWakefulIntent(intent);
}
 
开发者ID:MadKauz,项目名称:starcitizeninfoclient,代码行数:21,代码来源:PushIntentService.java

示例6: onStartCommand

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
public int onStartCommand(Intent intent, int flags, int startId) {
    synchronized (this) {
        this.counter++;
        if (startId > this.startId) this.startId = startId;
    }
    try {
        if (intent != null) {
            if (ACTION_INSTANCE_ID.equals(intent.getAction()) && intent.hasExtra(EXTRA_GSF_INTENT)) {
                startService((Intent) intent.getParcelableExtra(EXTRA_GSF_INTENT));
                return START_STICKY;
            }

            handleIntent(intent);

            if (intent.hasExtra(EXTRA_FROM))
                WakefulBroadcastReceiver.completeWakefulIntent(intent);
        }
    } finally {
        stop();
    }
    return START_NOT_STICKY;
}
 
开发者ID:microg,项目名称:android_external_GmsLib,代码行数:23,代码来源:InstanceIDListenerService.java

示例7: onStartCommand

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
	connectGoogleApiClient();
	initLocalVars(intent);
	showOngoingNotification();
	listenForUpdates();
	startCompassActivity();

	if(useWatchCompass) {
		setupLocationUtils(cacheLocation);
		locationUtils.startDirectionalTracking(getApplicationContext());
	}

	WakefulBroadcastReceiver.completeWakefulIntent(intent);

	return START_REDELIVER_INTENT;
}
 
开发者ID:cjmoran,项目名称:cgeo-wear,代码行数:18,代码来源:cgeoWearService.java

示例8: onHandleIntent

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@SuppressWarnings("MissingPermission")
@Override
protected void onHandleIntent(Intent intent) {
    try {
        if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PREF_ENABLE_CHECKIN, false)) {
            LastCheckinInfo info = CheckinManager.checkin(this, intent.getBooleanExtra(EXTRA_FORCE_CHECKIN, false));
            if (info != null) {
                Log.d(TAG, "Checked in as " + Long.toHexString(info.androidId));
                String accountType = AuthConstants.DEFAULT_ACCOUNT_TYPE;
                for (Account account : AccountManager.get(this).getAccountsByType(accountType)) {
                    PeopleManager.loadUserInfo(this, account);
                }
                McsService.scheduleReconnect(this);
                if (intent.hasExtra(EXTRA_CALLBACK_INTENT)) {
                    startService((Intent) intent.getParcelableExtra(EXTRA_CALLBACK_INTENT));
                }
            }
        }
    } catch (Exception e) {
        Log.w(TAG, e);
    } finally {
        WakefulBroadcastReceiver.completeWakefulIntent(intent);
        stopSelf();
    }
}
 
开发者ID:microg,项目名称:android_packages_apps_GmsCore,代码行数:26,代码来源:CheckinService.java

示例9: onStartCommand

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    synchronized (McsService.class) {
        if (rootHandler != null) {
            if (intent == null) return START_REDELIVER_INTENT;
            wakeLock.acquire(WAKELOCK_TIMEOUT);
            Object reason = intent.hasExtra(EXTRA_REASON) ? intent.getExtras().get(EXTRA_REASON) : intent;
            if (ACTION_CONNECT.equals(intent.getAction())) {
                rootHandler.sendMessage(rootHandler.obtainMessage(MSG_CONNECT, reason));
            } else if (ACTION_HEARTBEAT.equals(intent.getAction())) {
                rootHandler.sendMessage(rootHandler.obtainMessage(MSG_HEARTBEAT, reason));
            } else if (ACTION_SEND.equals(intent.getAction())) {
                handleSendMessage(intent);
            }
            WakefulBroadcastReceiver.completeWakefulIntent(intent);
        } else if (connectIntent == null) {
            connectIntent = intent;
        } else {
            WakefulBroadcastReceiver.completeWakefulIntent(intent);
        }
    }
    return START_REDELIVER_INTENT;
}
 
开发者ID:microg,项目名称:android_packages_apps_GmsCore,代码行数:24,代码来源:McsService.java

示例10: onStartCommand

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    LOGD(TAG, "onStartCommand: " + (intent != null ? intent.toString() : "no intent"));

    if (intent != null) {
        String action = intent.getAction();
        if (ACTION_UPDATE_WIDGETS.equals(action)) {
            handleUpdateWidgets(intent);

        } else if (ACTION_UPDATE_EXTENSIONS.equals(action)) {
            handleUpdateExtensions(intent);
        }

        // If started by a wakeful broadcast receiver, release the wake lock it acquired.
        WakefulBroadcastReceiver.completeWakefulIntent(intent);
    }

    return START_STICKY;
}
 
开发者ID:tedk,项目名称:Dash,代码行数:20,代码来源:DashClockService.java

示例11: onReceive

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
	if(prefs.getBoolean(RSSRelatedConstants.NOTIF_KEYS[0], true) && !prefs.getBoolean(MainActivity.FIRST_OPEN, true)) {
		RSSScheduledServiceHelper.startScheduled(context);
		WakefulBroadcastReceiver.completeWakefulIntent(intent);
	}
}
 
开发者ID:RoadRunner-Dollars,项目名称:Dollars-Android-App,代码行数:9,代码来源:RSSCheckOnBoot.java

示例12: onHandleIntent

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    Log.i(TAG, "Sync intent received. Fetching data from network.");
    sSunshineSyncEngine.performUpdate();
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    WakefulBroadcastReceiver.completeWakefulIntent(intent);
}
 
开发者ID:googlecodelabs,项目名称:getting-ready-for-android-n,代码行数:8,代码来源:SunshineSyncService.java

示例13: onHandleIntent

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    try {
        String to = intent.getStringExtra(TO_KEY);
        String text = intent.getStringExtra(TEXT_KEY);
        Log.i("SMS Dispatcher", "Delivering message to " + text);
        SmsManager sms = SmsManager.getDefault();
        Intent deliveredIntent = new Intent("sms_delivered");
        deliveredIntent.putExtra(SMSDispatcher.TO_KEY, to);
        deliveredIntent.putExtra(SMSDispatcher.TEXT_KEY, text);
        sms.sendTextMessage(to, null, text, null, null);
    } finally {
        WakefulBroadcastReceiver.completeWakefulIntent(intent);
    }
}
 
开发者ID:PacktPublishing,项目名称:Asynchronous-Android-Programming,代码行数:16,代码来源:SMSDispatcherIntentService.java

示例14: onHandleIntent

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    // Do the task here
    Log.i(CosiLoyaltyCardService.class.getName(), "Cosi Service running");

    // Release the wake lock provided by the WakefulBroadcastReceiver.
    WakefulBroadcastReceiver.completeWakefulIntent(intent);

    Device device = Device.registeredDevice();

    // cozy register device url
    designUrl = device.getUrl() + "/ds-api/request/loyaltycard/all/";
    syncUrl = device.getUrl() + "/ds-api/data/";


    // concatenate username and password with colon for authentication
    final String credentials = device.getLogin() + ":" + device.getPassword();
    authHeader = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);

    showNotification();

    if (isNetworkAvailable()) {
        try {
            EventBus.getDefault().post(new LoyaltyCardSyncEvent(SYNC_MESSAGE, "Getting loyalty cards from Cozy..."));
            getRemoteLoyaltyCards();
            mNotifyManager.cancel(notification_id);
            sendChangesToCozy();
            EventBus.getDefault().post(new LoyaltyCardSyncEvent(REFRESH, "Sync OK"));
        } catch (Exception e) {
            e.printStackTrace();
            mSyncRunning = false;
            EventBus.getDefault().post(new LoyaltyCardSyncEvent(SERVICE_ERROR, e.getLocalizedMessage()));
        }
    } else {
        mSyncRunning = false;
        EventBus.getDefault().post(new LoyaltyCardSyncEvent(SERVICE_ERROR, "No Internet connection"));
        mBuilder.setContentText("Sync failed because no Internet connection was available");
        mNotifyManager.notify(notification_id, mBuilder.build());
    }
}
 
开发者ID:hamzux,项目名称:cosi,代码行数:41,代码来源:CosiLoyaltyCardService.java

示例15: releaseWakeLock

import android.support.v4.content.WakefulBroadcastReceiver; //导入方法依赖的package包/类
private void releaseWakeLock() {
    if (gcmIntent.getBooleanExtra(Constants.EXTRA_HAS_WAKELOCK, false)) {
        Intent intent = gcmIntent;
        gcmIntent = null;
        WakefulBroadcastReceiver.completeWakefulIntent(intent);
    } else {
        gcmIntent = null;
    }
}
 
开发者ID:Swisyn,项目名称:SimpleGCM,代码行数:10,代码来源:GcmRegistrationService.java


注:本文中的android.support.v4.content.WakefulBroadcastReceiver.completeWakefulIntent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。