开发者

Getting data from an implicit intent

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'm having trouble finding details on how the information from the browser is transfered to my application ... since I need the exact website address that the browser was trying to access. I'm assuming th开发者_如何学编程at this data is stored in the intent extras, but to access those I need to know what the name of the keys are to get the info and what format, etc. Anyone know where this is documented? I'm guessing it's standardized.


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());


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜