@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AutofillManager af=getSystemService(AutofillManager.class); if (af.isAutofillSupported()) { if (af.hasEnabledAutofillServices()) { Toast.makeText(this, R.string.msg_ready, Toast.LENGTH_LONG).show(); finish(); } else { Uri uri=Uri.parse("package:"+getPackageName()); Intent i=new Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE, uri); startActivityForResult(i, REQUEST_ID); } } else { Toast.makeText(this, R.string.msg_not_supported, Toast.LENGTH_LONG).show(); finish(); } }
public static boolean isAutofillAvailable(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { // Autofill Framework is only available on Android O and higher return false; } AutofillManager afm = context.getSystemService(AutofillManager.class); // Returns whether autofill is supported by device or and enabled for current user. return afm != null && afm.isAutofillSupported() && afm.isEnabled(); }
@Override public void onClick(View view) { resetFields(); mAutofillManager.cancel(); } });
private void disableService() { if (mAutofillManager != null && mAutofillManager.hasEnabledAutofillServices()) { mAutofillManager.disableAutofillServices(); Snackbar.make(findViewById(R.id.settings_layout), R.string.settings_autofill_disabled_message, Snackbar.LENGTH_SHORT).show(); } else { logd("Sample service already disabled."); } }
@RequiresApi(api = Build.VERSION_CODES.O) private void requestAutofillIfEmptyCardholder() { if (cardholderEditText.getText().toString().isEmpty()) { cardholderEditText.setAutofillHints(View.AUTOFILL_HINT_NAME); AutofillManager autofillManager = getSystemService(AutofillManager.class); if (autofillManager != null && autofillManager.isEnabled()) { autofillManager.requestAutofill(cardholderEditText); } } }
private void startEnableService() { if (mAutofillManager != null && !mAutofillManager.hasEnabledAutofillServices()) { Intent intent = new Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE); intent.setData(Uri.parse("package:com.example.android.autofill.service")); logd(TAG, "enableService(): intent=%s", intent); startActivityForResult(intent, REQUEST_CODE_SET_DEFAULT); } else { logd("Sample service already enabled."); } }
@Override protected void notifyFocusLost(int virtualId) { mAutofillManager.notifyViewExited(this, virtualId); }
@Override protected void notifyFocusGained(int virtualId, Rect bounds) { mAutofillManager.notifyViewEntered(this, virtualId, bounds); }
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { context.getSystemService(AutofillManager.class) .notifyValueChanged(CreditCardExpirationDateCompoundView.this); }
private void finishIt() { StringBuilder message = new StringBuilder(getString(R.string.message_finished)) .append("\n\n"); for (int i = 0; i < mSteps.length; i++) { TextView label = (TextView) mSteps[i].getChildAt(0); EditText input = (EditText) mSteps[i].getChildAt(1); message.append(getString(R.string.message_step_description, label.getText(), input.getText())) .append('\n'); } mStatus.setText(message.toString()); mContainer.removeAllViews(); mFinished = true; AutofillManager afm = getSystemService(AutofillManager.class); if (afm != null) { afm.commit(); } updateButtons(); }
public List<FieldMetadata> initList() { return Arrays.asList( new FieldMetadata( mAfm.getNextAutofillId(), View.AUTOFILL_HINT_NAME, R.string.recycler_view_label_name, ), new FieldMetadata( mAfm.getNextAutofillId(), "bday-month", R.string.recycler_view_label_birthday_month, ), new FieldMetadata( mAfm.getNextAutofillId(), View.AUTOFILL_HINT_EMAIL_ADDRESS, R.string.recycler_view_label_email, ), new FieldMetadata( mAfm.getNextAutofillId(), View.AUTOFILL_HINT_PHONE, R.string.recycler_view_label_phone, ), new FieldMetadata( mAfm.getNextAutofillId(), "tel_extension", R.string.recycler_view_label_tel_extension,
@Override public void onClick(View view) { resetFields(); mAutofillManager.cancel(); } });
R.id.settingsSetServiceLabel, R.id.settingsSetServiceSwitch, mAutofillManager.hasEnabledAutofillServices(), (compoundButton, serviceSet) -> setService(serviceSet)); RadioGroup loggingLevelContainer = findViewById(R.id.loggingLevelContainer);
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (VERBOSE) Log.v(TAG, "onScroll(): " + distanceX + " - " + distanceY); if (mFocusedLine != null) { mAutofillManager.notifyViewExited(this, mFocusedLine.mFieldTextItem.id); } mTopMargin -= distanceY; mLeftMargin -= distanceX; invalidate(); return true; }
@Override public void onClick(View v) { AutofillManager afm = getSystemService(AutofillManager.class); if (afm != null) { afm.cancel(); } resetFields(); } });
@Override public void onClick(View v) { AutofillManager afm = getSystemService(AutofillManager.class); if (afm != null) { afm.cancel(); } resetFields(); } });
@Override public void onClick(View v) { AutofillManager afm = getSystemService(AutofillManager.class); if (afm != null) { afm.cancel(); } resetFields(); } });
@Override public void onClick(View v) { AutofillManager afm = getSystemService(AutofillManager.class); if (afm != null) { afm.cancel(); } resetFields(); } });
@Override public void onClick(View v) { AutofillManager afm = getSystemService(AutofillManager.class); if (afm != null) { afm.cancel(); } resetFields(); } });
@Override public void onClick(View v) { AutofillManager afm = getSystemService(AutofillManager.class); if (afm != null) { afm.cancel(); } resetFields(); } });