Java Code Examples for android.os.PersistableBundle#getString()

The following examples show how to use android.os.PersistableBundle#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlatformScheduler.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: PlatformScheduler.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example 3
Source File: PersistableBundleBuilder.java    From your-local-weather with GNU General Public License v3.0 6 votes vote down vote up
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;
    }
}
 
Example 4
Source File: NotificationJobService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: PlatformScheduler.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example 6
Source File: FetchJobService.java    From transistor-background-fetch with MIT License 6 votes vote down vote up
@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;
}
 
Example 7
Source File: PlatformScheduler.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example 8
Source File: DeleteWatchNextService.java    From leanback-homescreen-channels with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 9
Source File: PostProvisioningTask.java    From android-testdpc with Apache License 2.0 5 votes vote down vote up
@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));
    }
}
 
Example 10
Source File: ShortcutItem.java    From react-native-quick-actions with MIT License 5 votes vote down vote up
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;
}
 
Example 11
Source File: SyncDelegate.java    From materialistic with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 12
Source File: AddWatchNextService.java    From leanback-homescreen-channels with Apache License 2.0 5 votes vote down vote up
@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;

}
 
Example 13
Source File: DropTargetFragment.java    From android-DragAndDropAcrossApps with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 14
Source File: VoiceSettingParameter.java    From your-local-weather with GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example 15
Source File: Location.java    From your-local-weather with GNU General Public License v3.0 5 votes vote down vote up
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"));
    }
}
 
Example 16
Source File: LicenseKey.java    From your-local-weather with GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example 17
Source File: DropTargetFragment.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 18
Source File: BackgroundTaskSchedulerJobService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private static String getBackgroundTaskClassFromJobParameters(JobParameters jobParameters) {
    PersistableBundle extras = jobParameters.getExtras();
    if (extras == null) return null;
    return extras.getString(BACKGROUND_TASK_CLASS_KEY);
}
 
Example 19
Source File: UserInfo.java    From react-native-quick-actions with MIT License 4 votes vote down vote up
static UserInfo fromPersistableBundle(PersistableBundle bundle) {
    final UserInfo info = new UserInfo();
    info.url = bundle.getString("url");
    return info;
}
 
Example 20
Source File: LaunchIntentUtil.java    From android-testdpc with Apache License 2.0 4 votes vote down vote up
/**
 * @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;
}