package com.fan.test;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class TestActivity extends Activity {
/** Called when the activity is first created. */
@Override
//执行app时调用浏览器打开 baidu
//设定一个定时器,防止不能跳转
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Uri uri = Uri.parse("http://www.baidu.com");
final Intent it = new Intent(Intent.ACTION_VIEW, uri);
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
startActivity(it); //执行
}
};
timer.schedule(task, 1); //10秒后
}
//返回时自动退出
public void onRestart()
{
super.onRestart();
System.exit(0);
}
}
Android 浏览器的配置文件:
packages/apps/Browser/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fan.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/clients" android:label="@string/app_name">
<activity android:name=".TestActivity"
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:scheme="http" />
<data android:scheme="https" />
<data android:scheme="about" />
<data android:scheme="javascript" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>
如果需要对file支持,则加上
<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="file" />
</intent-filter>
文章出处: http://blog.csdn.net/yufan1987/article/details/6222540