使用Intent调用内置应用程序
2024-08-31 19:04:05
布局代码如下:
<?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);
} }
最新文章
- RadioGroup、RadioButton、CheckBox、Toast用法
- Java 基础知识相关好文章
- 转 @html.ActionLink的几种参数格式
- Oracle 权限(grant、revoke)
- SQL疑难杂症【5 】大量数据查询的时候要考虑结果为空的情况
- Swift学习笔记七
- 数据库中join的用法(on、left。right)
- C++返回引用的函数
- 【设计模式 - 13】之责任链模式(Chain Of Responsibility)
- 【HDOJ】2424 Gary&#39;s Calculator
- SQL Server 2005无日志文件附加数据库
- LinqToSql增加、修改、删除---(转载)
- Jenkins-FQA
- git命令别名(Alias)
- 2019-04-15 Python中的面向对象学习总结
- install scrapy
- mktemp 命令
- vue缓存页面【二】
- java设计模式-----21、备忘录模式
- AD集成库元件简写中英文对照表