我试图获取点击的网址以打开应用。我只是无法找到可以获取该信息的位置。我有一个清单,点击后打开应用程序。链接将是" http://host.com/file.html?param=1¶m2=2"我试图给应用程序处理。
<intent-filter>
<data android:scheme="http"
android:host="host.com"
android:pathPrefix="/file.html" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
修改
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Uri uri = intent.getData();
try {
url = new URL(uri.getScheme(), uri.getHost(), uri.getPath());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
答案 0 :(得分:5)
您应该能够使用以下内容获取活动中的意图数据:
Uri uri = this.getIntent().getData();
URL url = new URL(uri.getScheme(), uri.getHost(), uri.getPath());
答案 1 :(得分:0)
apiVersion: apps/v1
kind: Deployment
metadata:
name: database
labels:
app: database
spec:
replicas: 1
selector:
matchLabels:
app: database
template:
metadata:
labels:
app: database
spec:
containers:
- image: mariadb
name: database
env:
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
name: mysql
key: MYSQL_DATABASE
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: mysql
key: MYSQL_PASSWORD
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql
key: MYSQL_ROOT_PASSWORD
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: mysql
key: MYSQL_USER
ports:
- containerPort: 3306
name: database
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: database-claim0
您将不得不尝试/抓住周围。
答案 2 :(得分:0)
基本上,一旦您获得Uri(即getIntent().getData()
),您就可以将完整的URL读为uri.toString()
。假设您的android:host
有效且已设置,您还可以通过调用uri.getEncodedQuery()
来获取实际的查询数据。
如果需要,以下是工作样本中的更多详细信息:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="boo.acme.com"
android:scheme="http" />
</intent-filter>
Uri uri = this.getIntent().getData();
uri.toString()
生成“ http://boo.acme.com/?ll=43.455095,44.177416”,而uri.getEncodedQuery()
生成“ ll = 43.455095,44.177416”。希望有帮助!