Android 应用程序:如何从自定义 url 方案中读取获取参数? [英] Android App: How to read get parameters from a custom url scheme?

查看:23
本文介绍了Android 应用程序:如何从自定义 url 方案中读取获取参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我有与 如何在 Android 上实现我自己的 URI 方案

那里给出的答案对我有用.当自定义 url 被调用时 MyUriActivity's 方法 onCreateonStart 被调用.

The answer given there works for me. When the custom url is called MyUriActivity's methods onCreate and onStart are called.

但是

如何从 MyUriActivity 中访问获取参数?

How can I access the get parameters from within MyUriActivity?

示例:

myapp://path/to/what/i/want?d=This%20is%20a%20test

MyUriActivity 中,我需要读取获取参数 d 的值.

In MyUriActivity I need to read the value of get parameter d.

我该怎么做?

推荐答案

调用 getIntent().getData() 来检索 Uri,然后在其上调用getQueryParameter("d")获取值d.

Call getIntent().getData() to retrieve the Uri, then call getQueryParameter("d") on it to get the value of d.

这篇关于Android 应用程序:如何从自定义 url 方案中读取获取参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆