Android: userId - GET PHP 备选方案?

Android: userId - GET PHP alternative?

所以我有一个用户有 accounts/profiles 的应用程序,当你在搜索中输入名字和姓氏时,它会显示 activity 名为 ProfileViewer 并显示用户详细信息。

在 PHP 我会 link 喜欢:
<a href="http://website.com/profile.php?id=xxx">John Sample</a>

所以当用户点击它时 - 它会转到名为 profile.php 的 PHP 页面并从 MySQL 数据库 WHERE userid=xxx.

加载数据

那么在 Android 中有什么选择呢?我有点迷茫,关于如何识别正在加载 Activity 的用户 ID,我有哪些选择?

我可以使用 putExtra("userId", xxx) 然后使用 getExtra() 吗?

换句话说:如何让一个 activity 像接受 1 个参数然后在打开时使用它的页面一样工作?

在这些情况下,Intent extra 通常是可行的方法。

从第一个 activity 你会:

Intent intent = new Intent(this, SecondActivity.class);
intent.putExtra("userId", 1);
startActivity(intent);

然后您在第二个 activity 中检索信息,如下所示:

getIntent().getIntExtra("userId");