android之隐示意图跳转启动另一个activity

主面板布局:layout/activity_main.xml

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

    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:orientation="vertical">


    <Button
        android:id="@+id/btnStartSecondActivity"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="start SecondActivity" />
    <Button
        android:id="@+id/btnBrowser"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="浏览网页" />
    <Button
        android:id="@+id/btnCall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="拨打电话" />
    <Button
        android:id="@+id/btnDial"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="启动拨号面板" />
    <Button
        android:id="@+id/btnUninstall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="卸载应用程序" />
    <Button
        android:id="@+id/btnInstall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="安装应用程序" />
    <Button
        android:id="@+id/btnSendSms"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="发送短信" />
    <Button
        android:id="@+id/btnPlayMusic"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="播放音乐" />
    

</LinearLayout>

主面板调用java代码:

package com.sxt.day04_06;


import java.io.File;


import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;


public class MainActivity extends Activity implements OnClickListener {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setListener();
}


private void setListener() {
findViewById(R.id.btnBrowser).setOnClickListener(this);
findViewById(R.id.btnCall).setOnClickListener(this);
findViewById(R.id.btnDial).setOnClickListener(this);
findViewById(R.id.btnInstall).setOnClickListener(this);
findViewById(R.id.btnPlayMusic).setOnClickListener(this);
findViewById(R.id.btnSendSms).setOnClickListener(this);
findViewById(R.id.btnStartSecondActivity).setOnClickListener(this);
findViewById(R.id.btnUninstall).setOnClickListener(this);
}


@Override
public void onClick(View v) {
Intent intent = null;
switch (v.getId()) {
case R.id.btnBrowser:
//浏览网页
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.baidu.com"));
break;
case R.id.btnCall:
//打电话
intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:15555215554"));
break;
case R.id.btnDial:
//启动拨号面板
intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:68337799"));
break;
case R.id.btnInstall: {
//找到sdk中的安装文件,然后进行安装
// 找到sd卡的Download目录

File dir = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File file = new File(dir, "baidu_safe.apk");
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),
"application/vnd.android.package-archive");
}
break;
case R.id.btnPlayMusic:
//播放音乐文件
intent = new Intent(Intent.ACTION_VIEW);
File dir = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File file = new File(dir, "yielaixiang.mp3");
intent.setDataAndType(Uri.fromFile(file), "audio/mp3");
break;
case R.id.btnSendSms:
//发送短信
intent=new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("smsto:13377558899"));
intent.putExtra("sms_body", "hello android!");
break;
case R.id.btnStartSecondActivity://隐示意图跳转到另一个activity
intent=new Intent("com.sxt.day04_06.SecondActivity");
break;
case R.id.btnUninstall://卸载安装好的文件
intent=new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:com.sxt.day04_01"));
break;
}
startActivity(intent);
}


}

次面板布局:layout/activity_second.xml

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".SecondActivity" >


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />


</RelativeLayout>

次面板java代码:

package com.sxt.day04_06;


import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;


public class SecondActivity extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
Log.i("main","SecondActivity.onCreate()");
}


}

清单xml:AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sxt.day04_06"
    android:versionCode="1"
    android:versionName="1.0" >


    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.CALL_PHONE"/> (这两个是权限的)
<uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.sxt.day04_06.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.sxt.day04_06.SecondActivity"
            android:label="@string/title_activity_second" >
            <intent-filter>
                <action android:name="com.sxt.day04_06.SecondActivity"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
    </application>


</manifest>

效果:





转载于:https://www.cnblogs.com/qa962839575/p/4148592.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/406730.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux培训课程第六天:ppt以及笔记

第六天授课大纲介绍&#xff1a;第十讲&#xff1a;引导服务器dhcp和NIS这里dhcp服务比较简单,说明一下&#xff0c;首先将dhcp做成功,然后有个dhcp中继,做起来很简单,最主要大家要理解&#xff0c;中继是处在怎样的环境中&#xff0c;你怎样去搭配,这个明白了&#xff0c;下面…

微信公众号 H5 页面中点击一个按钮调起手机的电话拨打功能

1、在H5页面中调起手机的电话拨打功能其实很简单就能实现&#xff1a; <a href"tel:13556891235">点击给我打电话</a>2、在H5页面中调起手机发送短信&#xff1a; <a href"sms:18688888888">发短信</a>3、要想实现点击一个按钮我…

React开发(147):开发注意

## 列表查询做法&#xff1a; 以下查询条件值包括&#xff1a;普通查询和高级查询 1. 首先普通查询和高级查询的值是不相互关联的。 2. 点击查询按钮时会重置 pageIndex 为1&#xff0c;否则查询结果有误差 2. 重置不会重置列表 title 的 sort 和 filter&#xff0c;也不会重置…

中国移动话费查询,短信查询,各种免费查询!以后别打10086了

发送YE/CXYE到10086,余额查询 发送CXBX到10086&#xff0c;查询当月套餐剩余短信条数。 发送CXGFX到10086&#xff0c;查询当月飞信GPRS套餐剩余流量。 发送CXGTC到10086&#xff0c;查询当月GPRS套餐剩余流量。 发送CXCCT到10086&#xff0c;查询当月超级畅听套餐剩余流量。 发…

用宏定义写出swap(x,y)

#include <stdio.h>// SWAP(x, y) 交换x,y的值 #define SWAP(x, y) \(y) (x) (y); \(x) (y) - (x); \(y) (y) - (x);int main() {int a 3-2, b 5*8;SWAP(a, b);printf("%d, %d\n", a, b);return 0; }运行结果&#xff1a; 40, 1

利用XML生成Excel

先用Excel将我们要生成的表格设计好&#xff1a; 然后另存为XML表格&#xff1a; 将生成的Book1.xml复制到项目中并打开: 找到Table节点&#xff0c;将节点的ss:ExpandedRowCount”2” 删除掉 往下会看到我们刚输入的标题了吧 <Row> <Cell ss:StyleID"s23"&…

httpsqs消息队列

安装&#xff1a; 在安装httpsqs之前要安装 libevent-2.0.12-stable.tar.gz和okyocabinet-1.4.47.tar.gz ulimit -SHn 65535 1、安装libevent-2.0.12-stable.tar.gz wget http://httpsqs.googlecode.com/files/libevent-2.0.12-stable.tar.gz##下载 tar zxvf libevent-2.0.1…

找出数组中重复的数

/*问题描述&#xff1a;数组a[N]&#xff0c;存放了1至N-1个数&#xff0c;其中某个数重复一次。写一个函数&#xff0c;找出被重复的数字.时间复杂度必须为O(N)&#xff0c;函数原型&#xff1a;int do_dup(int a[], int N) */#include <stdio.h>// 返回数组中重复的数 …

vue-cli 4.x 配置 htmlWebpackPlugin.options.title

在 vue.config.js 中添加配置&#xff1a; // 修改或新增html-webpack-plugin的值&#xff0c;在index.html里面能读取htmlWebpackPlugin.options.titlechainWebpack: config >{config.plugin(html).tap(args > {args[0].title 你想要设置的title;return args;}) },

编程之美----子数组的最大乘积

问题&#xff1a;给定一个长度为N的整数数组&#xff0c;只允许用乘法&#xff0c;不能用除法&#xff0c;计算任意(N-1)个数的组合中乘积最大的一组&#xff0c;并写出算法的时间复杂度。 解法一&#xff1a;用一个数组保存从左边到右边前i个元素的乘积。用另一个数组保存从右…

android internet参数传递

当Activity与Activity/Service&#xff08;或其它情况&#xff09;有时与要进行参数传递&#xff0c;最常用也是最简单的方式就是通过Intent来处理。 看如下代码&#xff1a; Intent intent new Intent(...); Bundle bundle new Bundle(); bundle.putString("NAME&q…

vue获取前一个页面路由地址

可以使用&#xff1a; vue-router的beforeRouterEnter钩子 其实也就是一个路由守卫 <script> export default {data() {return {fromPath: "",};},beforeRouteEnter(to, from, next) {next((vm) > {// 通过 vm 访问组件实例,将值传入fromPathvm.fromPath …

自动化测试中Python与C/C++的混合使用

From: http://hi.baidu.com/sacmelody/blog/item/cf3ee7088d2112f036d12289.html 背景 项目的自动化测试中已经使用了基于Python脚本的框架&#xff0c;自动化过程中最关键的问题就是如何实现桩模块。运用 Python 强大的功能&#xff0c;实现任何桩模块都是可能的&#xff0c;但…

在IT的路上,我在成长

在IT的路上&#xff0c;我在成长。很荣幸地加入了博客园这个大家庭。 岁月的航船在不断航行&#xff0c;在成长的脚印我要深深留下&#xff0c;回首已往经历&#xff0c;发现自己成长的路上&#xff0c;将来也会有很多美好的回忆&#xff0c;以及丰硕的果实。转载于:https://ww…

React开发(149):ant design控制是否必填

<Form.Item label"原因">{getFieldDecorator(signInResson,form.getFieldsValue().signStatus QS_TESHU ||form.getFieldsValue().signStatus JS_TESHU? {initialValue: ,rules: [{ required: true, message: 请填写原因 }],}: { rules: [{ message: 请填写…

你如何摆平秋季问题皮肤

随着秋天的到来&#xff0c;不少MM的面部、身体的皮肤都出现了这样那样大大小小的问题。小编带着 网友们关注的“一箩筐”的问题&#xff0c;特别走访了成都市第二人民医院皮肤科路永红主任医师。让她从专业医师的角度来为大家上一堂课&#xff0c;专门讲解秋季问题皮肤如何预 …

display:none和visibility:hidden两者的区别

使用css让元素不可见的方法有很多种&#xff0c;裁剪、定位到屏幕外边、透明度变换等都是可以的。但是最常用两种方式就是设置元素样式为display: none或者visibility: hidden。很多公司的面试官也常常会问面试者这两者之间的区别。 display与元素的隐藏 如果给一个元素设置了…