我想在浏览器中实现文件关联,比如在浏览器中打开一个zip文件的url,直接关联我的程序,而不是启动下载管理器。
阅读了android的开发文档,有关信息如下描述:
Consider, for example, what the browser application does when the user follows a link on a web page. It first tries to display the data (as it could if the link was to an HTML page). If it can't display the data, it puts together an implicit intent with the scheme and data type and tries to start an activity that can do the job. If there are no takers, it asks the download manager to download the data.我实现了一个demo,在附件中,代码如下, 按照文档描述,这段代码应该可以实现这个功能,可实际上,根本没起作用,有谁知道到底是什么原因,谢谢.Androidmanifest.xml<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.glority"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:debuggable="true" >
<activity
android:name=".Test001Activity"
android:label="@string/app_name" >
<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:mimeType="*/*" />
</intent-filter>
</activity>
</application></manifest>
Test001Activity.java
public class Test001Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = getIntent();
String action = intent.getAction();
if (intent.ACTION_VIEW.equals(action)) {
Uri uri = (Uri) intent.getData();
}
}
}
阅读了android的开发文档,有关信息如下描述:
Consider, for example, what the browser application does when the user follows a link on a web page. It first tries to display the data (as it could if the link was to an HTML page). If it can't display the data, it puts together an implicit intent with the scheme and data type and tries to start an activity that can do the job. If there are no takers, it asks the download manager to download the data.我实现了一个demo,在附件中,代码如下, 按照文档描述,这段代码应该可以实现这个功能,可实际上,根本没起作用,有谁知道到底是什么原因,谢谢.Androidmanifest.xml<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.glority"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:debuggable="true" >
<activity
android:name=".Test001Activity"
android:label="@string/app_name" >
<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:mimeType="*/*" />
</intent-filter>
</activity>
</application></manifest>
Test001Activity.java
public class Test001Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = getIntent();
String action = intent.getAction();
if (intent.ACTION_VIEW.equals(action)) {
Uri uri = (Uri) intent.getData();
}
}
}
解决方案 »
- listview中按钮状态的保存,希望能过获得思路
- 如何获取摄像头的视频流呢?
- 配置文件出错?Unknown C compiler arm-linux-androideabi-gcc ?
- 动画Interpolater问题
- Android Box2D例子里面到底错在哪里?
- 如何指定webview可见部分从某一行开始?
- 急,项目中的难题有关系统后台服务和Activity的相关的一个问题
- 在listview点击item改变imageview的状态
- android蓝牙3.0方面的
- 请教大佬这个什么情况哈,适配是对的总是出错
- 请教各位大大有关一个XML的小问题
- [Android讨论] 如何在两个应用之间共用一个接口?请教一个自定义ClassLoader
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:mimeType="application/zip"/>
</intent-filter>