> Java > java지도 시간 > 본문

Android는 기본 브라우저를 호출하여 지정된 Url의 메소드 인스턴스를 엽니다.

高洛峰
풀어 주다: 2017-01-17 14:38:41
원래의
1686명이 탐색했습니다.

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.jb51.net);   
        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://play.jb51.net");   
            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()은 브라우저를 선택한 후 프로세스를 종료합니다.

지정된 URL을 열기 위해 기본 브라우저를 호출하는 더 많은 Android 방법 예제를 보려면 , 관련 기사는 PHP에 주목해주세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!