zoukankan      html  css  js  c++  java
  • 不使用webview,用手机浏览器的android app

    需求:wap站在手机上以App的形式打开,但不要嵌套WebView,只能以浏览器打开

    package com.gzz.whyinzi;
    
    import android.net.Uri;
    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.util.Log;
    import android.view.Menu;
    import android.view.View;
    
    public class MainActivity extends Activity {
        private static final String TAG = "ActivityDemo"; 
        
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            
            
            Intent intent = new Intent();        
            intent.setAction("android.intent.action.VIEW");    
            Uri content_url = Uri.parse(http://www.cnblogs.com);   
            intent.setData(content_url);  
            startActivity(intent);
            
            
        }
        
            @Override  
            protected void onResume() {  
                super.onResume(); 
                Intent intent = new Intent();        
                intent.setAction("android.intent.action.VIEW");    
                Uri content_url = Uri.parse("http://www.yinzimeijia.com");   
                intent.setData(content_url);  
                startActivity(intent);
                Log.e(TAG, "start onResume~~~");  
            }  
          
            @Override  
            protected void onStop() {  
                super.onStop();  
                this.finish();
                Log.e(TAG, "start onStop~~~");  
            }  
           
    
        
    
    }


     onResume()在没有默认浏览器的时候就起作用了,当没有默认浏览器的时候会弹出提示以哪个浏览器打开,如果点击取消就会出现黑色背景,为防止出现黑色背景,onsume()重新调用打开浏览器.

    onStop()在选择浏览器后结束进程.

  • 相关阅读:
    最近学习的 Node.js 之 http
    最近学习的 Node.js 基础:安装、环境配置、forever
    关于MySQL5.7 几天的总结(简单分区 & json类型)
    不会点git真不行啊.
    python爬虫基础_scrapy
    python爬虫基础_webwechat
    python爬虫基础_requests和bs4
    python之django母板页面
    python之django基础
    python网络之web框架
  • 原文地址:https://www.cnblogs.com/riskyer/p/3315503.html
Copyright © 2011-2022 走看看