Getting data from an implicit intent

后端 未结 2 1065
迷失自我
迷失自我 2020-12-18 12:42

I\'m writing an application that will be invoked when a specific website is accessed in the android browser. I\'ve configured my intent filters to make this happen, but I\'

相关标签:
2条回答
  • 2020-12-18 13:22

    The URI is in the Intent data. Activity.getIntent().getData().

    0 讨论(0)
  • 2020-12-18 13:33

    Yes you can get the data but you might need this in your manifest if you are doing implicit intents...

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="http"/> 
            </intent-filter>
    

    And then if you want the data to make a new URL do this inside you activity:

    Uri data = this.getIntent().getData();
    url = new URL(data.getScheme(), data.getHost(), data.getPath());
    
    0 讨论(0)
提交回复
热议问题