Android App 调用自带浏览器:
简单的一个功能点,像桌面快捷方式一样,调用浏览器打开一个网页。
- 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 {
-
- @Override
-
-
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- final Uri uri = Uri.parse("");
- 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);
- }
-
-
- public void onRestart()
- {
- super.onRestart();
- System.exit(0);
-
- }
- }
Android 浏览器的配置文件:
packages\apps\Browser\AndroidManifest.xml
- xml version="1.0" encoding="utf-8"?>
- <manifest xmlns: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>