【加入收藏】 【设为首页】 【进入论坛】 【站点地图】

你的位置:中国研发网 >> 手机研发 >> Android >> 详细内容 在线投稿

Android高手进阶教程 Android 在一个应用中如何启动另外一个已安装的应用

热度32票  浏览13次 【共0条评论】【我要评论 时间:2010年7月15日 15:51

  今天晚上Jimmy问了我一个问题,就是如何在一个应用中 通过某个事件,而去启动另外一个已安装的应用。所以愿意和大家分享一下!

  而为了能让大家更加容易的理解,我写了一个简单的Demo,我们的程序有俩个按钮,其中一个点击会启动我自己写的应用(一个3D应用为例),而另外一个按钮会启动系统自带的应用(如,日历,闹钟,计算器等等).这里我一日历为例子!

  首先看一下我们的效果图(点击第一个按钮为例):

  下面是Demo的详细步骤:

  一、新建一个Android工程命名为StartAnotherApplicationDemo.

  二、修改main.xml布局,代码如下:

  view plaincopy to clipboardprint?

  < ?xml version="1.0" encoding="utf-8"?>

  < LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

  android:orientation="vertical"

  android:layout_width="fill_parent"

  android:layout_height="fill_parent"

  >

  < TextView

  android:layout_width="fill_parent"

  android:layout_height="wrap_content"

  android:text="Welcome to Mr Wei's Blog."

  />

  < Button

  android:id="@+id/button"

  android:layout_width="fill_parent"

  android:layout_height="wrap_content"

  android:text="Start Another Application"

  />

  < Button

  android:id="@+id/start_calender"

  android:layout_width="fill_parent"

  android:layout_height="wrap_content"

  android:text="Start Calendar"

  />

  < /LinearLayout>

  三、修改主程序StartAnotherApplicationDemo.java代码如下:

  view plaincopy to clipboardprint?

  package com.android.tutor;

  import android.app.Activity;

第1页 第2页

( 0 B )

顶:4 踩:3
对本文中的事件或人物打分:
当前平均分:4 (2次打分)
对本篇资讯内容的质量打分:
当前平均分:1.5 (2次打分)
【已经有21人表态】
4票
感动
2票
路过
2票
高兴
2票
难过
2票
搞笑
4票
愤怒
2票
无聊
3票
同情
上一篇 下一篇
发表评论

网友评论仅供网友表达个人看法,并不表明本网同意其观点或证实其描述。

查看全部回复【已有0位网友发表了看法】