从网址打开特定活动 [英] Open specific activity from url

查看:51
本文介绍了从网址打开特定活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从浏览器android单击我的网站的网址后,我想打开我的应用android的特定活动.

I want open specific activity my app android after click url my website from browser android.

如果我的网址= <a href="http://myapp.com/aa-bb-cc-dd.html"> open activity </a>

我的活动是 DetailActivity ,如何在单击我的网址后打开此活动?

and my activity is DetailActivity , how to open this activity after click my url ?

并且我想在DetailActivity中为setText Textview使用" aa-bb-cc-dd ".

and I want "aa-bb-cc-dd" for setText Textview in DetailActivity .

text1.setText(" aa "); text2.setText(" bb "); text3.setText(" cc "); text4.setText("dd");

text1.setText("aa"); text2.setText("bb"); text3.setText("cc"); text4.setText("dd");

它是如何工作的?

推荐答案

在您的AndroidManifest.xml中,声明您的DetailActivity可以处理URL.

In your AndroidManifest.xml, declare that your DetailActivity can handle the URL.

<activity
    android:name=".DetailActivity"
    android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSER" />
        <data
            android:scheme="http"
            android:host="myapp.com"/>
    </intent-filter>
</activity>

然后您可以照常打开URL.

You can then open up the URL as usual.

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://myapp.com/aa-bb-cc.html"));
startActivity(intent);

在您的DetailActivity中,您可以按以下方式获取并解析传递给它的URL.

In your DetailActivity, you can get and parse the URL passed to it as follows.

Uri uri = getIntent().getData();
String path = uri.getPath();

这篇关于从网址打开特定活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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