zoukankan      html  css  js  c++  java
  • 使用Intent调用内置应用程序

    布局代码如下:

    <?xml version="1.0" encoding="utf-8" ?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />
        <Button
            android:id="@+id/btn_webbrowser"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Web Browser"
            android:onClick="onClickWebBrowser" />
        <Button
            android:id="@+id/btn_makcalls"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Make Calls"
            android:onClick="onClickMakeCalls" />
        
        <Button
            android:id="@+id/btn_showMap"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Show Map"
            android:onClick="onClickShowMap" />
    
    </LinearLayout>
    

    Activity代码如下:

    package com.lynx.intents;
    
    import android.net.Uri;
    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.view.View;
    
    public class IntentsActivity extends Activity {
    	
    	int request_Code=1;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
    
    
        public void onClickWebBrowser(View view){
        	Intent i=new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.amazon.com"));
        	startActivity(i);
        }
        
        public void onClickMakeCalls(View view){
        	Intent i=new Intent(android.content.Intent.ACTION_DIAL,Uri.parse("tel:+13503350416"));
        	startActivity(i);
        }
        
        public void onClickShowMap(View view){
        	Intent i=new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("geo:37.827500,-122.481670"));
        	startActivity(i);
        }
        
    }
    
  • 相关阅读:
    编译原理实验2简化版的C语言文法 159
    大数据概述 159
    第三次实验有限自动机的构造与识别 159
    Vue非单文件组件
    vue生命周期
    css3boxsizing
    openCV学习笔记(2)__openCV简单的图片处理(雪花,减少颜色)
    openCV学习笔记(1)__openCV与vs2010环境设置
    CentOS防火墙配置
    CentOS 6初始化配置
  • 原文地址:https://www.cnblogs.com/shanmao/p/3526312.html
Copyright © 2011-2022 走看看