Android 是否可以制作一个(单击图标后)只需在浏览器中加载页面的应用程序?
我已经建立了一个支持移动的网站,它提供了应用程序所能提供的大部分功能。然而,有些人仍然喜欢在手机上安装“应用程序”,因为它可以直接加载“应用程序”(网站),而不是让他们加载浏览器并键入URL 有没有一种方法可以在Android和iOS中创建这样的应用程序?这个想法是,有一个简单的自定义图标反映网站,一旦点击它加载浏览器与网站的URL已经输入Android 是否可以制作一个(单击图标后)只需在浏览器中加载页面的应用程序?,android,ios,mobile,web,Android,Ios,Mobile,Web,我已经建立了一个支持移动的网站,它提供了应用程序所能提供的大部分功能。然而,有些人仍然喜欢在手机上安装“应用程序”,因为它可以直接加载“应用程序”(网站),而不是让他们加载浏览器并键入URL 有没有一种方法可以在Android和iOS中创建这样的应用程序?这个想法是,有一个简单的自定义图标反映网站,一旦点击它加载浏览器与网站的URL已经输入 在Android和iOS上都能做到这一点似乎很简单,但在我的参考书中滚动只会产生一些概念,比如在应用程序的“主屏幕”中放置一个可点击的URL,而不是毫不费力
在Android和iOS上都能做到这一点似乎很简单,但在我的参考书中滚动只会产生一些概念,比如在应用程序的“主屏幕”中放置一个可点击的URL,而不是毫不费力的重定向。对于Android,我认为作者的评论是正确的。要改善用户体验,您可以做的是只进行一项透明的活动。在
onCreate
功能中,有一个进度对话框,显示一些消息。因为它是透明的,所以它只会显示对话框。然后从onCreate
中打开浏览器。在用户看来,您只是在打开浏览器。要使单个活动透明,请执行以下操作:
<activity android:name=".your.activity.declaration.here"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
基本上,将
android:theme=“@android:style/theme.transparent.NoTitleBar”
添加到清单中的活动声明中 对于安卓,我想说的是安卓的评论是正确的。要改善用户体验,您可以做的是只进行一项透明的活动。在onCreate
功能中,有一个进度对话框,显示一些消息。因为它是透明的,所以它只会显示对话框。然后从onCreate
中打开浏览器。在用户看来,您只是在打开浏览器。要使单个活动透明,请执行以下操作:
<activity android:name=".your.activity.declaration.here"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
基本上,将
android:theme=“@android:style/theme.transparent.NoTitleBar”
添加到清单中的活动声明中 如果要构建本机iOS应用程序,可以使用简单的UIWebView加载页面
例如,在根UIViewController中:
NSString* url = @"http://google.com";
NSURL* nsUrl = [NSURL URLWithString:url];
NSURLRequest* request = [NSURLRequest requestWithURL:nsUrl cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
[self.webView loadRequest:request];
如果您想构建本机iOS应用程序,可以使用简单的UIWebView加载页面 例如,在根UIViewController中:
NSString* url = @"http://google.com";
NSURL* nsUrl = [NSURL URLWithString:url];
NSURLRequest* request = [NSURLRequest requestWithURL:nsUrl cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
[self.webView loadRequest:request];
作为免责声明,我完全不知道苹果是否会接受这个应用商店,但实现这样一个东西是非常简单的。以下是我在appDelegate中更改的唯一代码:
#import "AppDelegate.h"
#import "WebViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
WebViewController *webVC = [[WebViewController alloc] initWithURLString:@"http://www.google.com"];
self.window.rootViewController = webVC;
[self.window makeKeyAndVisible];
return YES;
}
然后,我使用以下.h和.m文件对UIViewController进行了子类化:
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController <UIWebViewDelegate> {
NSString *_url;
}
- (id)initWithURLString:(NSString *)URLString;
@end
#import "WebViewController.h"
@interface WebViewController ()
@end
@implementation WebViewController
- (id)initWithURLString:(NSString *)URLString {
self = [super init];
_url = URLString;
return self;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.frame];
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight + UIViewAutoresizingFlexibleWidth;
webView.delegate = self;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]]];
[self.view addSubview:webView];
}
-(void)webViewDidStartLoad:(UIWebView *)webView {
// perhaps show some sort of loading message here
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {
// hide the loading message here
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
// also hide the loading message here and present the user with an appropriate error message
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
return YES;
}
@end
#导入
@界面WebViewController:UIViewController{
NSString*\uURL;
}
-(id)initWithURLString:(NSString*)URLString;
@结束
#导入“WebViewController.h”
@接口WebViewController()
@结束
@WebViewController的实现
-(id)initWithURLString:(NSString*)URLString{
self=[super init];
_url=URLString;
回归自我;
}
-(无效)视图将显示:(BOOL)动画{
[超级视图将显示:动画];
UIWebView*webView=[[UIWebView alloc]initWithFrame:self.view.frame];
webView.autoresizingMask=UIViewAutoresizingFlexibleHeight+UIViewAutoresizingFlexibleWidth;
webView.delegate=self;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]];
[self.view addSubview:webView];
}
-(void)webView加载:(UIWebView*)webView{
//可能在这里显示某种加载消息
}
-(无效)webViewDidFinishLoad:(UIWebView*)webView{
//在此处隐藏加载消息
}
-(void)webView:(UIWebView*)webView失败加载错误:(NSError*)错误{
//还可以在此处隐藏加载消息,并向用户显示相应的错误消息
}
-(BOOL)webView:(UIWebView*)webView应加载WithRequest:(NSURLRequest*)请求导航类型:(UIWebViewNavigationType)导航类型{
返回YES;
}
@结束
结果如下:
<activity android:name=".your.activity.declaration.here"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
希望有帮助 作为免责声明,我完全不知道苹果是否会在应用商店接受这一点,但实现这一点非常简单。以下是我在appDelegate中更改的唯一代码:
#import "AppDelegate.h"
#import "WebViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
WebViewController *webVC = [[WebViewController alloc] initWithURLString:@"http://www.google.com"];
self.window.rootViewController = webVC;
[self.window makeKeyAndVisible];
return YES;
}
然后,我使用以下.h和.m文件对UIViewController进行了子类化:
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController <UIWebViewDelegate> {
NSString *_url;
}
- (id)initWithURLString:(NSString *)URLString;
@end
#import "WebViewController.h"
@interface WebViewController ()
@end
@implementation WebViewController
- (id)initWithURLString:(NSString *)URLString {
self = [super init];
_url = URLString;
return self;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.frame];
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight + UIViewAutoresizingFlexibleWidth;
webView.delegate = self;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]]];
[self.view addSubview:webView];
}
-(void)webViewDidStartLoad:(UIWebView *)webView {
// perhaps show some sort of loading message here
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {
// hide the loading message here
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
// also hide the loading message here and present the user with an appropriate error message
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
return YES;
}
@end
#导入
@界面WebViewController:UIViewController{
NSString*\uURL;
}
-(id)initWithURLString:(NSString*)URLString;
@结束
#导入“WebViewController.h”
@接口WebViewController()
@结束
@WebViewController的实现
-(id)initWithURLString:(NSString*)URLString{
self=[super init];
_url=URLString;
回归自我;
}
-(无效)视图将显示:(BOOL)动画{
[超级视图将显示:动画];
UIWebView*webView=[[UIWebView alloc]initWithFrame:self.view.frame];
webView.autoresizingMask=UIViewAutoresizingFlexibleHeight+UIViewAutoresizingFlexibleWidth;
webView.delegate=self;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]];
[self.view addSubview:webView];
}
-(void)webView加载:(UIWebView*)webView{
//可能在这里显示某种加载消息
}
-(无效)webViewDidFinishLoad:(UIWebView*)webView{
//在此处隐藏加载消息
}
-(void)webView:(UIWebView*)webView失败加载错误:(NSError*)错误{
//还可以在此处隐藏加载消息,并向用户显示相应的错误消息
}
-(BOOL)webView:(UIWebView*)webView应加载WithRequest:(NSURLRequest*)请求导航类型:(UIWebViewNavigationType)导航类型{
返回YES;
}
@结束
结果如下:
<activity android:name=".your.activity.declaration.here"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
希望有帮助 对于iOS,“移动web外壳”类型的应用程序将在应用程序审查过程中被拒绝
从(您需要使用AppleId登录)
2.12不太有用、不独特的应用程序只是作为应用程序捆绑的网站,或者不提供任何la