android - 如何将数据解析为来自其他类的链接 api
问题描述
我是这里的新手。我想问一下是否可以在改造链接中添加固定值的数据。
这是我的代码:(这里我有一个值从我的模块中获取我的用户 ID。)
public class ScheduleModule extends Fragment {
public static String qqst;
View inflatedView = null;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
inflatedView = inflater.inflate(R.layout.fragment_schedule_module, container, false);
ggst = Settings.Secure.getString(getContext().getContentResolver(),
Settings.Secure.ANDROID_ID);
我想在我的api上添加这个。通过将数据传递给链接但它不起作用..
public interface API {
@GET("api/Database/GetSchedule?
serialNumber="+"Schedule.ggst")
Call<List<ScheduleDetails>> getSchedData();
}
Schedule.ggst
无法将我模块中的数据链接到 api 。但在我的情况下,这是我喜欢做的,以便在每个设备中都有一个唯一的 id 访问我的自定义 api。
这是我想访问的示例数据:
api/Database/GetSchedule?serialNumber=5d2a2dd4c787e116
解决方案
我认为您可以使用如下查询参数
@GET("api/Database/GetSchedule)
Call<List<ScheduleDetails>> getSchedData(@Query("serialNumber") int serialNumber);
并这样称呼它
APIService.getSchedData(ggst);
推荐阅读
- python - 如何使用输出成功调用变色功能?
- flutter - 如何修复“引发另一个异常:NoSuchMethodError:getter 'value' was called on null”错误
- asp.net-core - 如何使用 asp-for 获取模型的完整命名空间路径
- excel - 什么是“禁用宏”错误弹出窗口?我可以用它代替 msgbox 吗?
- c# - 在 Microsft Graph 中调用并显示 List memberOf 的结果
- c++ - 为什么当我使用双精度时,Qt<->Matlab 正确写入和读取我的字节,但对于存储 uint32 的字节却不正确?
- c# - 如何从 HttpClient 实例获取会话 ID?
- spring-boot - 创建测试数据时出现 NullPointerException
- react-native - 如何从屏幕组件访问 createStackNavigator 中定义的默认路由参数
- video-streaming - 有没有办法识别流视频的编解码器?