第十四章,通过Intent打开其他软件(Android)

上微信头条,,C币就是你的CSDN社区之星徐宜生:爱分享、爱极客! 最流行的语言想学就学写博文,传代码,赚C币

第十四章,通过Intent打开其他软件(Android)

分类:Android学习

androidintent

activity_main.xml

<LinearLayout xmlns:android=""xmlns:tools=""android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context=".MainActivity" ><Buttonandroid:id="@+id/main_web"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="web" /><Buttonandroid:id="@+id/main_tel"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="tel" /></LinearLayout>MainActivity.java

package com.example.demo0623;import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.Window;import android.widget.Button;public class MainActivity extends Activity implements OnClickListener {private Button main_web, main_tel;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);// 去掉标题requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_main);// 初始化控件initView();}private void initView() {// TODO Auto-generated method stubmain_web = (Button) this.findViewById(R.id.main_web);main_tel = (Button) this.findViewById(R.id.main_tel);main_web.setOnClickListener(this);main_tel.setOnClickListener(this);}// 点击事件@Overridepublic void onClick(View arg0) {// 跳转到浏览器中打开baiduif (arg0.getId() == R.id.main_web) {Intent intent = new Intent(Intent.ACTION_VIEW);intent.setData(Uri.parse(""));startActivity(intent);// 跳转到拨打号码页面} else if (arg0.getId() == R.id.main_tel) {Intent intent = new Intent(Intent.ACTION_DIAL);intent.setData(Uri.parse("tel:10086"));startActivity(intent);}}}

运行截图:

点击web

点击tel

上一篇第二十三章,(C++ primer笔记)string的理解(C++)

顶0踩0

主题推荐猜你在找

查看评论

* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场

核心技术类目

把艰辛的劳作看作是生命的必然,

第十四章,通过Intent打开其他软件(Android)

相关文章:

你感兴趣的文章:

标签云: