Những gì bạn mô tả có thể dễ dàng thực hiện bằng cách sử dụng WebView
.
WebView
(từ android developers): Chế độ xem hiển thị trang web. Lớp này là cơ sở để bạn có thể cuộn trình duyệt web của riêng mình hoặc chỉ hiển thị một số nội dung trực tuyến trong Hoạt động của bạn. Nó sử dụng công cụ kết xuất WebKit để hiển thị các trang web và bao gồm các phương pháp để điều hướng tiến và lùi thông qua lịch sử, phóng to và thu nhỏ, thực hiện tìm kiếm văn bản và hơn thế nữa.
Dưới đây là một ứng dụng mẫu đơn giản:
public class WebActivity extends Activity {
WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState)
{
final Activity mActivity = this;
super.onCreate(savedInstanceState);
// Adds Progrss bar Support
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
// Makes Progress bar Visible
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(http://your.url.com);
mWebView.setWebChromeClient(new WebChromeClient()
{
public void onProgressChanged(WebView view, int progress)
{
//Make the bar disappear after URL is loaded, and changes string to Loading...
mActivity .setTitle("Loading...");
mActivity .setProgress(progress * 100); //Make the bar disappear after URL is loaded
// Return the app name after finish loading
if(progress == 100)
{
financialPortalActivity.setTitle(R.string.yourWebSiteName);
}
}
});
}
}
và một tập tin bố trí rất đơn giản: main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Tất nhiên bạn sẽ phải thiết lập một sự cho phép trong Manifest của bạn:
<uses-permission android:name="android.permission.INTERNET" />
Nó chấp nhận bất cứ điều gì, miễn là nó không phải là phần mềm độc hại ... không cần đánh giá. – Rotemmiz