public static void requestSync(Context context, String inputId, boolean currentProgramOnly) { PersistableBundle pBundle = new PersistableBundle(); pBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); pBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); pBundle.putString(SyncJobService.BUNDLE_KEY_INPUT_ID, inputId); pBundle.putBoolean(SyncJobService.BUNDLE_KEY_CURRENT_PROGRAM_ONLY, currentProgramOnly); JobInfo.Builder builder = new JobInfo.Builder(REQUEST_SYNC_JOB_ID, new ComponentName(context, SyncJobService.class)); JobInfo jobInfo = builder .setExtras(pBundle) .setOverrideDeadline(SyncJobService.OVERRIDE_DEADLINE_MILLIS) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .build(); scheduleJob(context, jobInfo); Intent intent = new Intent(SyncJobService.ACTION_SYNC_STATUS_CHANGED); intent.putExtra(SyncJobService.BUNDLE_KEY_INPUT_ID, inputId); intent.putExtra(SyncJobService.SYNC_STATUS, SyncJobService.SYNC_STARTED); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); }
@Override public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); setContentView(R.layout.fragment_about); webView = findViewById(R.id.web_view); webView.setNetworkAvailable(false); webView.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url){ if(url.startsWith("http")){ depth++; return false; } else { url = url.replace("file:///android_asset/",""); loadAsset(url); return true; } } }); loadAsset("file:///android_asset/about.html"); }
public static void scheduleAddWatchNextRequest(Context context, ClipData clipData) { JobScheduler scheduler = (JobScheduler) context.getSystemService(JOB_SCHEDULER_SERVICE); PersistableBundle bundle = new PersistableBundle(); bundle.putString(ID_KEY, clipData.getClipId()); bundle.putString(CONTENT_ID_KEY, clipData.getContentId()); bundle.putLong(DURATION_KEY, clipData.getDuration()); bundle.putLong(PROGRESS_KEY, clipData.getProgress()); bundle.putString(TITLE_KEY, clipData.getTitle()); bundle.putString(DESCRIPTION_KEY, clipData.getDescription()); bundle.putString(CARD_IMAGE_URL_KEY, clipData.getCardImageUrl()); scheduler.schedule(new JobInfo.Builder(1, new ComponentName(context, AddWatchNextService.class)) .setMinimumLatency(0) .setExtras(bundle) .build()); }
@ReplaceMethod public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { if (!com_rakuten_tech_mobile_perf_onCreate_tracking) { com_rakuten_tech_mobile_perf_onCreate_tracking = true; int id = Tracker.startMethod(this, "onCreate"); try { onCreate(savedInstanceState, persistentState); } finally { Tracker.endMethod(id); com_rakuten_tech_mobile_perf_onCreate_tracking = false; } } else { onCreate(savedInstanceState, persistentState); } }
@Override public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { /* To maintain activity state across reboots the system saves and restore critical information for all tasks and their activities. Information known by the system includes the activity stack order, each task’s thumbnails and each activity’s and task's Intents. For Information that cannot be retained because they contain Bundles which can’t be persisted a new constrained version of Bundle, PersistableBundle is added. PersistableBundle can store only basic data types. To use it in your Activities you must declare the new activity:persistableMode attribute in the manifest. */ outPersistentState.putInt(KEY_EXTRA_NEW_DOCUMENT_COUNTER, mDocumentCounter); super.onSaveInstanceState(outState, outPersistentState); }
public static JobInfo.Builder createProcessJobInfoBuilder(Context context, int jobId, QueuedSiteToSiteClientConfig queuedSiteToSiteClientConfig, ParcelableQueuedOperationResultCallback parcelableQueuedOperationResultCallback) { JobInfo.Builder builder = new JobInfo.Builder(jobId, new ComponentName(context, SiteToSiteJobService.class)); PersistableBundle persistableBundle = new PersistableBundle(); SerializationUtils.putParcelable(queuedSiteToSiteClientConfig, persistableBundle, "config"); SerializationUtils.putParcelable(parcelableQueuedOperationResultCallback, persistableBundle, "callback"); builder.setExtras(persistableBundle); return builder; }
/***************************************************/ @Override public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { super.onSaveInstanceState(outState, outPersistentState); outState.putString(EXTRA_BILL_ID,mBillId); outState.putString(EXTRA_BILL_NAME,mBillName); }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public static <T extends Parcelable> void putParcelable(T parcelable, PersistableBundle persistableBundle, String name) { if (parcelable == null) { return; } PersistableBundle bundle = new PersistableBundle(); bundle.putString("class", parcelable.getClass().getCanonicalName()); bundle.putString("data", Base64.encodeToString(marshallParcelable(parcelable), 0)); persistableBundle.putPersistableBundle(name, bundle); }
@Override public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onPostCreate(savedInstanceState, persistentState); // Restore state from PersistableBundle if (persistentState != null) { mDocumentCounter = persistentState.getInt(KEY_EXTRA_NEW_DOCUMENT_COUNTER); } }
@Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState);/* setContentView(R.layout.measurement_activity); findViews(); setListener();*/ }
@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; }
public static void setUpPeriodicSync(Context context, String inputId) { PersistableBundle pBundle = new PersistableBundle(); pBundle.putString(SyncJobService.BUNDLE_KEY_INPUT_ID, inputId); JobInfo.Builder builder = new JobInfo.Builder(PERIODIC_SYNC_JOB_ID, new ComponentName(context, SyncJobService.class)); JobInfo jobInfo = builder .setExtras(pBundle) .setPeriodic(SyncJobService.FULL_SYNC_FREQUENCY_MILLIS) .setPersisted(true) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .build(); scheduleJob(context, jobInfo); }
@Override public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { super.onSaveInstanceState(outState, outPersistentState); outState.putString("firstname", firstname.getText().toString()); outState.putString("lastname", lastname.getText().toString()); outState.putString("email", username.getText().toString()); setViews(false); }
@Override public void callActivityOnCreate(Activity activity, Bundle icicle, PersistableBundle persistentState) { if (icicle != null) { BundleCompat.clearParcelledData(icicle); } super.callActivityOnCreate(activity, icicle, persistentState); }
@Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { setContentView(R.layout.activity_wellcomeinour); ViewUtils.inject(this); httpUtils=new HttpUtils(); mobile=telephoneNum.getText().toString(); }
@Override public void onPostCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) { super.onPostCreate(savedInstanceState, persistentState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(ThemeUtils.getColorById(this, R.color.theme_color_primary_dark)); ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription (null, null, ThemeUtils.getThemeAttrColor(this, android.R.attr.colorPrimary)); setTaskDescription(taskDescription); } }
private void agendarJob() { JobInfo.Builder b = new JobInfo.Builder(JOB_ID, new ComponentName(this, DownloadJobService.class)); PersistableBundle pb=new PersistableBundle(); pb.putBoolean(KEY_DOWNLOAD, true); b.setExtras(pb); //criterio de rede b.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY); //b.setRequiredNetworkType(JobInfo.NETWORK_TYPE_NONE); //define intervalo de periodicidade //b.setPeriodic(getPeriod()); //exige (ou nao) que esteja conectado ao carregador b.setRequiresCharging(false); //persiste (ou nao) job entre reboots //se colocar true, tem que solicitar permissao action_boot_completed b.setPersisted(false); //exige (ou nao) que dispositivo esteja idle b.setRequiresDeviceIdle(false); //backoff criteria (linear ou exponencial) //b.setBackoffCriteria(1500, JobInfo.BACKOFF_POLICY_EXPONENTIAL); //periodo de tempo minimo pra rodar //so pode ser chamado se nao definir setPeriodic... b.setMinimumLatency(3000); //mesmo que criterios nao sejam atingidos, define um limite de tempo //so pode ser chamado se nao definir setPeriodic... b.setOverrideDeadline(6000); jobScheduler.schedule(b.build()); }
/** * Start a QuickPeriodicJob * @param jobId The id of the QuickPeriodicJob to start. It must match an id of a QuickPeriodicJob that was added using QuickPeriodicJobCollection.add(). If the job does not exist, nothing will happen. * @param periodicInterval The interval in milliseconds that you want this job to run (example 30000 would be 30 seconds) */ public void start(int jobId, long periodicInterval) { ComponentName component = new ComponentName(context, QuickPeriodicJobRunner.class); JobInfo.Builder builder = new JobInfo.Builder(jobId, component); builder.setOverrideDeadline(periodicInterval); builder.setMinimumLatency(periodicInterval); PersistableBundle bundle = new PersistableBundle(); bundle.putLong("interval",periodicInterval); builder.setExtras(bundle); JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); jobScheduler.schedule(builder.build()); storeIsJobScheduled(jobId, true, periodicInterval); }
@CallSuper @Override public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { super.onSaveInstanceState(outState, outPersistentState); LogUtils.verbose(className + " onSaveInstanceState"); }
@Override public void onRestoreInstanceState(Bundle savedInstanceState, PersistableBundle persistentState) { super.onRestoreInstanceState(savedInstanceState, persistentState); }
@Override public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); serverUrl = getIntent().getStringExtra("server_url"); }
@Override public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); }
public static void onCreate(Activity target, Bundle icicle, PersistableBundle persistentState, boolean after) { if (DEBUG_LIFECYCLE) ApkLogger.get().debug("LifeCycle_onCreate " + (after ? "after" : ""), null); }
@Override public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { super.onSaveInstanceState(outState, outPersistentState); outState.putString(SELECTED_PICTURE, currentPhotoPath); }
JobConfig(Parcel in) { this.virtualJobId = in.readInt(); this.serviceName = in.readString(); this.extras = in.readParcelable(PersistableBundle.class.getClassLoader()); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void callActivityOnSaveInstanceState(Activity activity, Bundle outState, PersistableBundle outPersistentState) { base.callActivityOnSaveInstanceState(activity, outState, outPersistentState); }
@Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); setContentView(R.layout.activity_event_details); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void callActivityOnRestoreInstanceState(Activity activity, Bundle savedInstanceState, PersistableBundle persistentState) { HookActivity_LifeCycle.onRestoreInstanceState(activity, savedInstanceState, persistentState, false); mInstrumentation.callActivityOnRestoreInstanceState(activity, savedInstanceState, persistentState); HookActivity_LifeCycle.onRestoreInstanceState(activity, savedInstanceState, persistentState, true); }
@Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); PushAgent.getInstance(this).onAppStart();//友盟关于推送的统计 }
final void performCreate(Bundle icicle, PersistableBundle persistentState) { restoreHasCurrentPermissionRequest(icicle); onCreate(icicle, persistentState); mActivityTransitionState.readState(icicle); performCreateCommon(); }
public static void onSaveInstanceState(Activity activity, Bundle outState, PersistableBundle persistentState, boolean after) { if (DEBUG_LIFECYCLE) ApkLogger.get().debug("LifeCycle_onSaveInstanceState " + (after ? "after" : ""), null); }
@Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); gcAndFinalize(); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void callActivityOnRestoreInstanceState(Activity activity, Bundle savedInstanceState, PersistableBundle persistentState) { base.callActivityOnRestoreInstanceState(activity, savedInstanceState, persistentState); }
public static void onRestoreInstanceState(Activity activity, Bundle outState, PersistableBundle persistentState, boolean after) { if (DEBUG_LIFECYCLE) ApkLogger.get().debug("LifeCycle_onRestoreInstanceState " + (after ? "after" : ""), null); }
@Deprecated @Override public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { super.onSaveInstanceState(outState, outPersistentState); handleSave(outState); }