移动现有的网络应用程序将使用浏览器的包装原生手机应用程序 [英] move existing web app into a native phone app using a browser wrapper

查看:112
本文介绍了移动现有的网络应用程序将使用浏览器的包装原生手机应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,可以说有一个全功能的响应红宝石Rails的Web应用程序。这个应用程序的工作原理,并在手机上看起来不错。不幸的是,Web应用程序无法从手机应用商店看到,因为它不是一个原生应用程序。从技术上讲,你可以打开了浏览器,但显然这不是最佳的放置在智能手机的图标。

So lets say there is a fully functional responsive ruby rails web app. This app works and looks great on mobile phones. Unfortunately, this web app can't be seen from the mobile phone app stores, because it's not a native app. Technically you could place an icon on a smart phone that opens up the browser, but obviously this is not optimal.

有没有一种方法来创建本机应用程序(Android设备,iPhone),其本质上只是一个浏览器,没有导航栏?该浏览器的包装只会加载Web应用程序和行为,就像你已经打开了浏览器。

Is there a way to create a native app (Android, iPhone) that is essentially just a browser, without the navigation bar? This browser's wrapper would just load the web app and behave just like you had opened up the browser.

我已经调查选项,如PhoneGap的钛,但似乎有将是一个显著量重写,并有很少的资金用于此。

I have looked into options such as Phonegap and Titanium, but it seems there would be a significant amount of rewriting, and there are very little funds for this.

推荐答案

我真的不知道iOS的,但这样做在Android将是很容易的。

I don't really know iOS, but doing it in Android will be really easy.

首先,这是你的活动:

package com.example.my_browser;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

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);
        WebView browser = (WebView)findViewById(R.id.browser);
        browser.loadUrl("http://google.com"); //Replace google.com with you webapp's URL
    }
}

这是你的main.xml中的布局:

This is your main.xml layout:

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

和您将需要请求网络权限在AndroidManifest.xml中:

And you will need to request internet permission in AndroidManifest.xml:

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

我刚刚测试了这个在模拟器和它的作品。

I just tested this in an emulator and it works.

这篇关于移动现有的网络应用程序将使用浏览器的包装原生手机应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆