XML - Main

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.prize.mydemo.MainActivity"
tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp"> <Button
android:id="@+id/button1"
android:text="写入号码"
android:layout_width="0dp"
android:layout_height="48dp"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="97dp"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button2"
android:text="写入次数"
android:layout_width="0dp"
android:layout_height="48dp"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toTopOf="@+id/button4"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="60dp"
app:layout_constraintLeft_toLeftOf="parent" /> <Button
android:id="@+id/buuton3"
android:layout_width="0dp"
android:text="清除全部"
android:layout_height="48dp"
android:layout_marginStart="25dp"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="@+id/button4"
android:layout_marginEnd="25dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="25dp"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="60dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/button2"
app:layout_constraintVertical_bias="1.0"
app:layout_constraintHorizontal_bias="0.509" />
<Button
android:id="@+id/button4"
android:layout_width="0dp"
android:text="执行测试"
android:layout_height="48dp"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
android:layout_marginStart="25dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="25dp"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="139dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="0.68" />
<EditText
android:id="@+id/text1"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_marginStart="25dp"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="@+id/button1"
android:layout_marginEnd="25dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="37dp"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="48dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<EditText
android:id="@+id/text2"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_marginEnd="25dp"
android:layout_marginStart="25dp"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="@+id/button2"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="58dp"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="55dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/button1" />
<TextView
android:id="@+id/text3"
android:text=" 暗淡"
android:layout_width="47dp"
android:layout_height="27dp"
tools:layout_constraintBottom_creator="1"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="-5dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp" />
</android.support.constraint.ConstraintLayout>

Main的class

package com.example.prize.mydemo;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText; public class MainActivity extends AppCompatActivity {
public static String [] PhoneAndTime = new String[2];
@Override
protected void onCreate(Bundle savedInstanceState) {
//初始化界面
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // 写入号码
//find按键
Button SetPhone = (Button)findViewById(R.id.button1);
//创建按键监听
SetPhone.setOnClickListener(new View.OnClickListener(){ @Override
public void onClick(View view) {
//获取EditText
EditText phoneText = (EditText)findViewById(R.id.text1);
PhoneAndTime[0] = String.valueOf(phoneText.getText());
Log.e("Demo1","号码是:"+PhoneAndTime[0]);
Log.e("Demo1","点击写入号码"); }
}); // 重新写入号码
/*
Button ClearPhone = (Button)findViewById(R.id.button2);
ClearPhone.setOnClickListener(new View.OnClickListener(){ @Override
public void onClick(View view) {
EditText PhoneText = (EditText)findViewById(R.id.text2);
PhoneText.setText("");
PhoneAndTime[1] = String.valueOf(PhoneText.getText()); Log.e("Demo1","点击重新写入号码"); }
});
*/ //写入次数 Button SetTime = (Button)findViewById(R.id.button2);
SetTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText timetext = (EditText)findViewById(R.id.text2) ;
PhoneAndTime [1] = timetext.getText().toString();
Log.e("Demo1","写入次数是:"+PhoneAndTime[1]);
Log.e("Demo1","点击写入次数"); }
}); //重新写入
Button ClearTime = (Button)findViewById(R.id.buuton3);
ClearTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText phoneText = (EditText)findViewById(R.id.text1);
EditText timetext = (EditText)findViewById(R.id.text2) ;
phoneText.setText("");
timetext.setText("");
PhoneAndTime[0] = "";
PhoneAndTime[1] = ""; Log.e("Demo1","点击重新写入");
}
}); //执行测试
Button Run = (Button)findViewById(R.id.button4);
Run.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//new 新的Intent
Intent data = new Intent(MainActivity.this,Demo_1.class);
//用Bundle 携带数组
Bundle bundle = new Bundle();
bundle.putStringArray("phone_data",PhoneAndTime);
//将 data Intent 添加Bundle
data.putExtras(bundle);
startActivity(data);
Log.e("Demo1","点击执行测试"); }
});
}
}

执行拨号的后台 XML


<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.prize.mydemo.Demo_1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拨号" /> </android.support.constraint.ConstraintLayout>

执行拨号的后台 class


package com.example.prize.mydemo;

import android.content.Intent;
import android.content.IntentSender;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast; public class Demo_1 extends AppCompatActivity { @Override
protected void onResume() {
super.onResume();
Intent intentdata = getIntent();
Bundle bundle = this.getIntent().getExtras();
String [] data = bundle.getStringArray("phone_data");
Intent intent2 = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+data[0]));
Log.e("Demo1","正在拨号");
int time = Integer.parseInt(data[1]);
for(int i=0;i<time;i++) {
try {
startActivity(intent2);
Toast.makeText(Demo_1.this,"这是第:"+i+"拨号",Toast.LENGTH_SHORT).show(); } catch (Exception e) {
e.printStackTrace();
Log.e("Demo1", "异常");
}
try {
Log.e("Demo1","正在通话,等待120秒");
Thread.sleep(120000);
Log.e("Demo1","等待结束");
} catch (InterruptedException e) {
e.printStackTrace();
Log.e("Demo1", "异常2");
}
}
Log.e("Demo1","拨号循环已经跳出");
Toast.makeText(Demo_1.this,"测试完成",Toast.LENGTH_SHORT).show();
finish(); }
}

自写-自动拨号测试app的更多相关文章

  1. 深圳电信光纤用户必备:简单破解中兴ZXA10 F460光电猫,实现WIFI和自动拨号功能

    最近搬家,ADSL转成光纤宽带,下载速度非常给力.原来的ADSL路由器派不上用场,电信的安装人员也给开通了wifi功能,只是wifi无法上网,而且拨号一定需要用电脑连网线进行拨号.以前是直接把拨号账户 ...

  2. WinCE下GPRS自动拨号软件(GPRS AutoDial)

    之前在WinCE下调试USB的3G Modem时,写过一个拨号助手RASManager,基本能用.后来车机卖到俄罗斯去,客户老M提供了一个更好的GPRS自动拨号软件GPRS AutoDial,功能完善 ...

  3. OSX10.12搭建IPv6本地环境测试APP

    前记 最近刚换了工作,生活终于又安定下来了,又可以更博了 正文 最近公司在上线APP(整体全是用JS去写的,就用了我原生的一个控制器),然后APP就去上线,就被苹果巴巴给拒了.通过阅读苹果回复的邮件, ...

  4. Samba共享及自动挂载测试

    要求: 1.在server0服务器上安装配置samba,工作组为STAFF,共享目录/smb1, 共享名smb1,仅允许192.168.100.0/24网段中的主机访问.samba用户user1可以读 ...

  5. python--selenium实用的自动生成测试HTML报告方法--HTMLTestRunner

    python--selenium实用的自动生成测试HTML报告方法--HTMLTestRunner 下面给大家介绍下用HTMLTestRunner模块自动生成测试报告的方法. 一.首先我们导入unit ...

  6. 如何实现ADSL宽带用户开机自动拨号与定时拨号

    在宽带拨号网络的环境下,要通过手动拨号认证才能上网.下面给大家介绍怎么设置开机自动拨号上网以及定时拨号上网. 这也是为一个叫CHY的2B准备的技术套餐,不需要用到网上说的自动拨号软件,只要在主机上设置 ...

  7. python基础语法13 内置模块 subprocess,re模块,logging日志记录模块,防止导入模块时自动执行测试功能,包的理论

    subprocess模块: - 可以通过python代码给操作系统终端发送命令, 并且可以返回结果. sub: 子    process: 进程 import subprocess while Tru ...

  8. 怎样在IDEA中使用JUnit4和JUnitGenerator V2.0自动生成测试模块

     因为项目的需要,所以研究了一下自动生成测试代码.将经验记录下来,总会有用的.我个人认为,好记性不如多做笔记多反思总结. 1.    前提条件 开发环境已正确配置 工程已解决JUnit依赖关系(pom ...

  9. Fiddler抓包测试App接口

    Fiddler抓包测试App接口 使用Fiddler对手机App应用进行抓包,可以对App接口进行测试,也可以了解App传输中流量使用及请求响应情况,从而测试数据传输过程中流量使用的是否合理. 抓包过 ...

随机推荐

  1. 黄聪:jquery+Datatables出现数据过长,表格不自动换行,columns设置width失效的办法

    添加下面的CSS代码即可: table.dataTable.nowrap th, table.dataTable.nowrap td{white-space: normal !important;}

  2. Java第08次实验提纲(多线程)

    PTA与参考资料 题集:多线程 多线程实验参考文件 ThreadReading 实验-基础部分 基础题目MyThread类.PrintTask(讲解线程Thread与任务Runnable相分离的概念) ...

  3. java中的自定义注解的使用

    https://www.cnblogs.com/acm-bingzi/p/javaAnnotation.html

  4. SpringSecurity-ChannelProcessingFilter的作用

    ChannelProcessingFilter决定的是web请求的通道,即http或https. 在springsecurity配置文件中添加这样一行 <intercept-url patter ...

  5. Hadoop概念学习系列之关于hadoop-2.2.0和hadoop2.6.0的winutils.exe、hadoop.dll版本混用(易出错)(四十三)

    问题详情是 2016-12-10 23:24:13,317 INFO [org.apache.hadoop.metrics.jvm.JvmMetrics] - Initializing JVM Met ...

  6. Spring @Async使用方法总结

    引言: 在Java应用中,绝大多数情况下都是通过同步的方式来实现交互处理的:但是在处理与第三方系统交互的时候,容易造成响应迟缓的情况,之前大部分都是使用多线程来完成此类任务,其实,在spring 3. ...

  7. 3d图像坐标轴及css3属性的讲解

    3d立体坐标轴 如有不知道各种插件的怎么办? 网上查,百度 1.css选择器: 1.id 2.class 3.标签 4.子代 5.后代 6.交集 7.并级 8.通配符 9.结构 10.伪类 11.属性 ...

  8. 用JavaScript来生成HTML

    用JavaScript来生成HTML <style> table{ border-top: 1px #ff0000 solid; border-left: 1px #ff0000 soli ...

  9. [UE4]创建游戏、加入游戏

    google搜: UE4 compile dedicated server,编译UE4专用服务器 UE4默认网络端口可以在引擎配置文件中修改: 一.创建文件.需要修改一下工程的配置文件DefaultE ...

  10. 本机无法访问虚拟机里面的nginx的80端口

    在虚拟机VMware上装好了centos6.9,并配好了nginx,但是本机就是无法访问.具体情况如下1.本机能ping通虚拟机2.虚拟机也能ping通本机3.虚拟机能访问自己的web4.本机无法访问 ...