如何制作应用程序图标进入网站

时间:2014-11-10 14:12:30

标签: android

我正在尝试为我的网站制作应用。该应用程序非常基本,我希望从用户手机点击应用程序图标直接进入我的网站。我认为这将是非常直接的,但是我很难找到关于如何实现这一目标的任何事情。我在http://developer.android.com/guide/webapps/webview.html找到了一个教程,我实际上实现了这个并且它有效。但是我不想让它去webview。我希望它在点击时直接进入原生手机浏览器。有人可以详细解释如何做到这一点。

1 个答案:

答案 0 :(得分:-1)

为了回答,但不应该做出这种应用。

首先创建一个android项目,在layout文件夹中创建一个android xml文件。

将其命名为mywebview.xml。并删除代码下面的所有代码和粘贴。

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

然后创建一个活动,例如下面在src文件夹中给出的

 public class ExampleActivity extends Activity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            WebView myWebView = (WebView) findViewById(R.id.webview);
           myWebView.loadUrl("your url");
        }
        @Override
        protected void onStart() {
            super.onStart();
            // The activity is about to become visible.
        }
        @Override
        protected void onResume() {
            super.onResume();
            // The activity has become visible (it is now "resumed").
        }
        @Override
        protected void onPause() {
            super.onPause();
            // Another activity is taking focus (this activity is about to be "paused").
        }
        @Override
        protected void onStop() {
            super.onStop();
            // The activity is no longer visible (it is now "stopped")
        }
        @Override
        protected void onDestroy() {
            super.onDestroy();
            // The activity is about to be destroyed.
        }
    }
在您的Android清单中

删除所有活动并添加

<activity android:name=".ExampleActivity" android:icon="@drawable/app_icon">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

 <uses-permission android:name="android.permission.INTERNET" />

然后在android清单文件中添加使用权限。

相关问题