android.os.PersistableBundle#getString ( )源码实例Demo

下面列出了android.os.PersistableBundle#getString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Telegram   文件: PlatformScheduler.java
@Override
public boolean onStartJob(JobParameters params) {
  logd("PlatformSchedulerService started");
  PersistableBundle extras = params.getExtras();
  Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
  if (requirements.checkRequirements(this)) {
    logd("Requirements are met");
    String serviceAction = extras.getString(KEY_SERVICE_ACTION);
    String servicePackage = extras.getString(KEY_SERVICE_PACKAGE);
    Intent intent =
        new Intent(Assertions.checkNotNull(serviceAction)).setPackage(servicePackage);
    logd("Starting service action: " + serviceAction + " package: " + servicePackage);
    Util.startForegroundService(this, intent);
  } else {
    logd("Requirements are not met");
    jobFinished(params, /* needsReschedule */ true);
  }
  return false;
}
 
源代码2 项目: TelePlus-Android   文件: PlatformScheduler.java
@Override
public boolean onStartJob(JobParameters params) {
  logd("PlatformSchedulerService started");
  PersistableBundle extras = params.getExtras();
  Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
  if (requirements.checkRequirements(this)) {
    logd("Requirements are met");
    String serviceAction = extras.getString(KEY_SERVICE_ACTION);
    String servicePackage = extras.getString(KEY_SERVICE_PACKAGE);
    Intent intent = new Intent(serviceAction).setPackage(servicePackage);
    logd("Starting service action: " + serviceAction + " package: " + servicePackage);
    Util.startForegroundService(this, intent);
  } else {
    logd("Requirements are not met");
    jobFinished(params, /* needsReschedule */ true);
  }
  return false;
}
 
public static android.location.Address toAddress(PersistableBundle persistableBundle) {
    if (persistableBundle == null) {
        return null;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        String language = persistableBundle.getString("language");
        String country = persistableBundle.getString("country");
        String variant = persistableBundle.getString("variant");
        Locale addressLocale = new Locale(language, country, variant);
        android.location.Address address = new android.location.Address(addressLocale);
        address.setLocality(persistableBundle.getString("locality"));
        address.setSubLocality(persistableBundle.getString("subLocality"));
        address.setAdminArea(persistableBundle.getString("adminArea"));
        address.setSubAdminArea(persistableBundle.getString("subAdminArea"));
        address.setCountryName(persistableBundle.getString("countryName"));
        return address;
    } else {
        return null;
    }
}
 
源代码4 项目: TelePlus-Android   文件: PlatformScheduler.java
@Override
public boolean onStartJob(JobParameters params) {
  logd("PlatformSchedulerService started");
  PersistableBundle extras = params.getExtras();
  Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
  if (requirements.checkRequirements(this)) {
    logd("Requirements are met");
    String serviceAction = extras.getString(KEY_SERVICE_ACTION);
    String servicePackage = extras.getString(KEY_SERVICE_PACKAGE);
    Intent intent = new Intent(serviceAction).setPackage(servicePackage);
    logd("Starting service action: " + serviceAction + " package: " + servicePackage);
    Util.startForegroundService(this, intent);
  } else {
    logd("Requirements are not met");
    jobFinished(params, /* needsReschedule */ true);
  }
  return false;
}
 
@Override
public boolean onStartJob(final JobParameters params) {
    PersistableBundle extras = params.getExtras();
    final String taskId = extras.getString(BackgroundFetchConfig.FIELD_TASK_ID);

    CompletionHandler completionHandler = new CompletionHandler() {
        @Override
        public void finish() {
            Log.d(BackgroundFetch.TAG, "- jobFinished");
            jobFinished(params, false);
        }
    };
    BGTask task = new BGTask(taskId, completionHandler, params.getJobId());
    BackgroundFetch.getInstance(getApplicationContext()).onFetch(task);

    return true;
}
 
源代码6 项目: 365browser   文件: NotificationJobService.java
/**
 * Called when a Notification has been interacted with by the user. If we can verify that
 * the Intent has a notification Id, start Chrome (if needed) on the UI thread.
 *
 * We get a wakelock for our process for the duration of this method.
 *
 * @return True if there is more work to be done to handle the job, to signal we would like our
 * wakelock extended until we call {@link #jobFinished}. False if we have finished handling the
 * job.
 */
@Override
public boolean onStartJob(final JobParameters params) {
    PersistableBundle extras = params.getExtras();
    if (!extras.containsKey(NotificationConstants.EXTRA_NOTIFICATION_ID)
            || !extras.containsKey(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN)
            || !extras.containsKey(NotificationConstants.EXTRA_NOTIFICATION_INFO_TAG)) {
        return false;
    }

    Intent intent =
            new Intent(extras.getString(NotificationConstants.EXTRA_NOTIFICATION_ACTION));
    intent.putExtras(new Bundle(extras));

    ThreadUtils.assertOnUiThread();
    NotificationService.dispatchIntentOnUIThread(this, intent);

    // TODO(crbug.com/685197): Return true here and call jobFinished to release the wake
    // lock only after the event has been completely handled by the service worker.
    return false;
}
 
源代码7 项目: Telegram-FOSS   文件: PlatformScheduler.java
@Override
public boolean onStartJob(JobParameters params) {
  logd("PlatformSchedulerService started");
  PersistableBundle extras = params.getExtras();
  Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS));
  if (requirements.checkRequirements(this)) {
    logd("Requirements are met");
    String serviceAction = extras.getString(KEY_SERVICE_ACTION);
    String servicePackage = extras.getString(KEY_SERVICE_PACKAGE);
    Intent intent =
        new Intent(Assertions.checkNotNull(serviceAction)).setPackage(servicePackage);
    logd("Starting service action: " + serviceAction + " package: " + servicePackage);
    Util.startForegroundService(this, intent);
  } else {
    logd("Requirements are not met");
    jobFinished(params, /* needsReschedule */ true);
  }
  return false;
}
 
/**
 * DragEvents can contain additional data packaged in a {@link PersistableBundle}.
 * Extract the extras from the event and return the String stored for the
 * {@link #EXTRA_IMAGE_INFO} entry.
 */
private String getExtra(DragEvent event) {
    // The extras are contained in the ClipDescription in the DragEvent.
    ClipDescription clipDescription = event.getClipDescription();
    if (clipDescription != null) {
        PersistableBundle extras = clipDescription.getExtras();
        if (extras != null) {
            return extras.getString(EXTRA_IMAGE_INFO);
        }
    }
    return null;
}
 
源代码9 项目: your-local-weather   文件: LicenseKey.java
public LicenseKey(PersistableBundle persistentBundle) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        id = persistentBundle.getLong("id");
        requestUri = persistentBundle.getString("requestUri");
        initialLicense = persistentBundle.getString("initialLicense");
        token = persistentBundle.getString("token");
        lastCallTimeInMs = persistentBundle.getLong("lastCallTimeInMs");
    }
}
 
源代码10 项目: your-local-weather   文件: Location.java
public Location(PersistableBundle persistentBundle) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        id = persistentBundle.getLong("id");
        latitude = persistentBundle.getDouble("latitude");
        longitude = persistentBundle.getDouble("longitude");
        orderId = persistentBundle.getInt("orderId");
        localeAbbrev = persistentBundle.getString("locale");
        locale = new Locale(localeAbbrev);
        nickname = persistentBundle.getString("nickname");;
        accuracy = new Double(persistentBundle.getDouble("accuracy")).floatValue();
        locationSource = persistentBundle.getString("locationSource");
        lastLocationUpdate = persistentBundle.getLong("lastLocationUpdate");
        address = PersistableBundleBuilder.toAddress(persistentBundle.getPersistableBundle("address"));
    }
}
 
源代码11 项目: your-local-weather   文件: VoiceSettingParameter.java
public VoiceSettingParameter(PersistableBundle persistentBundle) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        id = persistentBundle.getLong("id");
        voiceSettingId = persistentBundle.getLong("voiceSettingId");
        paramTypeId = persistentBundle.getInt("paramTypeId");
        paramBooleanValue = mapIntToBoolean(persistentBundle.getInt("paramBooleanValue"));
        paramLongValue = persistentBundle.getLong("paramLongValue");
        paramStringValue = persistentBundle.getString("paramStringValue");
    }
}
 
/**
 * DragEvents can contain additional data packaged in a {@link PersistableBundle}.
 * Extract the extras from the event and return the String stored for the
 * {@link #EXTRA_IMAGE_INFO} entry.
 */
private String getExtra(DragEvent event) {
    // The extras are contained in the ClipDescription in the DragEvent.
    ClipDescription clipDescription = event.getClipDescription();
    if (clipDescription != null) {
        PersistableBundle extras = clipDescription.getExtras();
        if (extras != null) {
            return extras.getString(EXTRA_IMAGE_INFO);
        }
    }
    return null;
}
 
@Override
protected Void doInBackground(Void... params) {
    PersistableBundle bundle = mJobParameters.getExtras();
    if (bundle == null) {
        Log.e(TAG, "No data passed to task for job " + mJobParameters.getJobId());
        return null;
    }

    String id = bundle.getString(ID_KEY);
    String contentId = bundle.getString(CONTENT_ID_KEY);
    long duration = bundle.getLong(DURATION_KEY);
    long progress = bundle.getLong(PROGRESS_KEY);
    String title = bundle.getString(TITLE_KEY);
    String description = bundle.getString(DESCRIPTION_KEY);
    String cardImageURL = bundle.getString(CARD_IMAGE_URL_KEY);

    ClipData clipData = new ClipData.Builder().setClipId(id)
            .setContentId(contentId)
            .setDuration(duration)
            .setProgress(progress)
            .setTitle(title)
            .setDescription(description)
            .setCardImageUrl(cardImageURL)
            .build();

    SampleTvProvider.addWatchNextContinue(getApplicationContext(), clipData);
    return null;

}
 
@Override
protected Void doInBackground(Void... params) {
    PersistableBundle bundle = mJobParameters.getExtras();
    if (bundle == null) {
        Log.e(TAG, "No data passed to task for job " + mJobParameters.getJobId());
        return null;
    }

    String clipId = bundle.getString(ID_KEY);
    SampleTvProvider.deleteWatchNextContinue(getApplicationContext(), clipId);
    return null;
}
 
源代码15 项目: materialistic   文件: SyncDelegate.java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
Job(PersistableBundle bundle) {
    id = bundle.getString(EXTRA_ID);
    connectionEnabled = bundle.getInt(EXTRA_CONNECTION_ENABLED) == 1;
    readabilityEnabled = bundle.getInt(EXTRA_READABILITY_ENABLED) == 1;
    articleEnabled = bundle.getInt(EXTRA_ARTICLE_ENABLED) == 1;
    commentsEnabled = bundle.getInt(EXTRA_COMMENTS_ENABLED) == 1;
    notificationEnabled = bundle.getInt(EXTRA_NOTIFICATION_ENABLED) == 1;
}
 
源代码16 项目: react-native-quick-actions   文件: ShortcutItem.java
static ShortcutItem fromPersistableBundle(PersistableBundle bundle) {
    final ShortcutItem item = new ShortcutItem();
    item.type = bundle.getString("type");
    item.title = bundle.getString("title");
    item.icon = bundle.getString("icon");
    item.userInfo = UserInfo.fromPersistableBundle(bundle.getPersistableBundle("userInfo"));
    return item;
}
 
源代码17 项目: android-testdpc   文件: PostProvisioningTask.java
@TargetApi(VERSION_CODES.O)
private void maybeSetAffiliationIds(PersistableBundle extras) {
    if (extras == null) {
        return;
    }
    String affiliationId = extras.getString(LaunchIntentUtil.EXTRA_AFFILIATION_ID);
    if (affiliationId != null) {
        mDevicePolicyManager.setAffiliationIds(
                getComponentName(mContext),
                Collections.singleton(affiliationId));
    }
}
 
private static String getBackgroundTaskClassFromJobParameters(JobParameters jobParameters) {
    PersistableBundle extras = jobParameters.getExtras();
    if (extras == null) return null;
    return extras.getString(BACKGROUND_TASK_CLASS_KEY);
}
 
源代码19 项目: react-native-quick-actions   文件: UserInfo.java
static UserInfo fromPersistableBundle(PersistableBundle bundle) {
    final UserInfo info = new UserInfo();
    info.url = bundle.getString("url");
    return info;
}
 
源代码20 项目: android-testdpc   文件: LaunchIntentUtil.java
/**
 * @returns the account name in the given bundle, as populated by
 * {@link #prepareDeviceAdminExtras(Intent, PersistableBundle)}
 */
public static String getAddedAccountName(PersistableBundle persistableBundle) {
    return persistableBundle != null
            ? persistableBundle.getString(EXTRA_ACCOUNT_NAME, null) : null;
}