从浏览器的网址链接,打开我的Android应用(Open my Android app from U

2019-06-27 15:21发布

我知道我的问题是被问了很多次这里,但我尝试了所有的答案,仍然有问题我的问题是,我想我的应用程序从移动浏览器中打开URL抛

以下是我在mainfeast.xml文件写

       <activity
        android:name=".Login"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <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="" android:scheme="mpay2park" />
        </intent-filter>

仍然解决不了这个问题,我想知道,我是否应该在Login.java活动写任何东西,或没有什么,什么是URLthat我应该为此编写

谢谢

Answer 1:

您可以使用以下清单文件打开ABC:从浏览器地址栏//xyz.com:

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.sample.openfrombrowser.MainActivity"
        android:exported="true"
        android:label="@string/app_name"
        android:launchMode="singleInstance" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <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="xyz.com"
                android:scheme="abc" />
        </intent-filter>
        <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="google.co.in"
                android:pathPrefix="/"
                android:scheme="http" />
            <data
                android:host="www.google.co.in"
                android:pathPrefix="/"
                android:scheme="http" />
        </intent-filter>
    </activity>
</application>

这将要求选项(与你的应用程序的名称)在对话框中打开这个网址。

希望所以这会为你工作。

请享用。



Answer 2:

我解决我的问题,这是我写mainfest文件

  <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:scheme="mpay2park"/>
        </intent-filter>

我改变了Android浏览器和Opera Mini的打开我喜欢和它的工作非常适合我



文章来源: Open my Android app from URL link from browser
标签: android url