admin 管理员组文章数量: 1086019
public class MyActivity extends Activity { /** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
public class WebViewActivity extends Activity { /** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.webview); Uri data = getIntent().getData(); WebView view = (WebView) findViewById(R.id.webview); view.getSettings().setJavaScriptEnabled(true); view.loadUrl(data.toString()); view.setWebViewClient(new MyClient()); } private class MyClient extends WebViewClient{ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } }
AndroidManifest.xml:
<activity android:name="MyActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name="com.example.myapp.WebViewActivity" android:configChanges="orientation|keyboardHidden" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http"/> </intent-filter> </activity>
webview.xml:
<LinearLayout xmlns:android="http://schemas.android/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/webview"/> </LinearLayout>
版权声明:本文标题:在App内点击链接打开网页(不用浏览器) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/b/1737922281a1896679.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论