有关 Android 上帐户创建和同步的问题

发布于 2024-10-20 05:51:44 字数 937 浏览 4 评论 0原文

我一直在阅读 Android 网站上的开发文档中的示例代码,特别是:

http://developer.android.com/resources/samples/SampleSyncAdapter/src/com/example/android/samplesync/authenticator/AuthenticatorActivity.html

这是示例应用程序的唯一活动。它引用 onCreate 方法中的意图。我不明白这个意图来自哪里,或者如果这是应用程序使用的唯一活动,它应该包含什么。

Log.i(TAG, "loading data from Intent");
        final Intent intent = getIntent();
        mUsername = intent.getStringExtra(PARAM_USERNAME);
        mAuthtokenType = intent.getStringExtra(PARAM_AUTHTOKEN_TYPE);
        mRequestNewAccount = mUsername == null;
        mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);

这是处理意图的代码块。为什么您会对应用程序中的唯一活动有意图?这个应用程序的调用方式是否不寻常?清单不包括活动的意图过滤器...我想我对整个事情有点迷失了!如果有人能纠正我的话那就太好了,谢谢。

I've been reading the sample code from the dev docs on Android's site, specifically this:

http://developer.android.com/resources/samples/SampleSyncAdapter/src/com/example/android/samplesync/authenticator/AuthenticatorActivity.html

Which is the sole activity of the sample app. It refers to an intent in the onCreate method. I don't understand where this intent is coming from, or what it should contain if this is the only activity the app utilizes.

Log.i(TAG, "loading data from Intent");
        final Intent intent = getIntent();
        mUsername = intent.getStringExtra(PARAM_USERNAME);
        mAuthtokenType = intent.getStringExtra(PARAM_AUTHTOKEN_TYPE);
        mRequestNewAccount = mUsername == null;
        mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);

That's the block of code working with the intent. Why would you have an intent for the only activity in the app? Is this app called in an unusual way? The Manifest does not include an intent filter for the activity... I guess I'm just a bit lost on this whole thing! If someone could set me straight that'd be great, thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

日裸衫吸 2024-10-27 05:51:44
  1. 为什么您会对应用中的唯一活动有意图?

    getIntent() 获取启动此活动的意图。

  2. 此应用程序的调用方式是否异常?

    我猜这个活动是从另一个应用程序或活动以编程方式调用的,因为它已经传递了一些额外的数据:getStringExtra()用于从启动它的意图中提取一些数据。 putExtra..getExtra.. 是一种在 Activity 启动时在 Activity 之间传递数据的方法。

  1. Why would you have an intent for the only activity in the app?

    getIntent() gets you the intent that started this activity.

  2. Is this app called in an unusual way?

    I guess this activity is called programmatically from another app or activity, since it has been passed some extra data: getStringExtra() is used to extract some data from the intent that started it. putExtra.. and getExtra.. is a way to pass data between activities when they are started.

听闻余生 2024-10-27 05:51:44

在该特定示例中,意图是从

In that specific example, the intent is sent from the addAccount method in Authenticator.java. That method is called by the OS when you click the Add Account button in the Accounts & sync settings screen and choose your account type.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文