XML - Main

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent"
  7. tools:context="com.example.prize.mydemo.MainActivity"
  8. tools:layout_editor_absoluteY="81dp"
  9. tools:layout_editor_absoluteX="0dp">
  10. <Button
  11. android:id="@+id/button1"
  12. android:text="写入号码"
  13. android:layout_width="0dp"
  14. android:layout_height="48dp"
  15. tools:layout_constraintTop_creator="1"
  16. tools:layout_constraintRight_creator="1"
  17. android:layout_marginStart="25dp"
  18. android:layout_marginEnd="25dp"
  19. app:layout_constraintRight_toRightOf="parent"
  20. android:layout_marginTop="97dp"
  21. tools:layout_constraintLeft_creator="1"
  22. app:layout_constraintLeft_toLeftOf="parent"
  23. app:layout_constraintTop_toTopOf="parent" />
  24. <Button
  25. android:id="@+id/button2"
  26. android:text="写入次数"
  27. android:layout_width="0dp"
  28. android:layout_height="48dp"
  29. tools:layout_constraintRight_creator="1"
  30. tools:layout_constraintBottom_creator="1"
  31. app:layout_constraintBottom_toTopOf="@+id/button4"
  32. android:layout_marginStart="25dp"
  33. android:layout_marginEnd="25dp"
  34. app:layout_constraintRight_toRightOf="parent"
  35. tools:layout_constraintLeft_creator="1"
  36. android:layout_marginBottom="60dp"
  37. app:layout_constraintLeft_toLeftOf="parent" />
  38. <Button
  39. android:id="@+id/buuton3"
  40. android:layout_width="0dp"
  41. android:text="清除全部"
  42. android:layout_height="48dp"
  43. android:layout_marginStart="25dp"
  44. tools:layout_constraintTop_creator="1"
  45. tools:layout_constraintRight_creator="1"
  46. tools:layout_constraintBottom_creator="1"
  47. app:layout_constraintBottom_toBottomOf="@+id/button4"
  48. android:layout_marginEnd="25dp"
  49. app:layout_constraintRight_toRightOf="parent"
  50. android:layout_marginTop="25dp"
  51. tools:layout_constraintLeft_creator="1"
  52. android:layout_marginBottom="60dp"
  53. app:layout_constraintLeft_toLeftOf="parent"
  54. app:layout_constraintTop_toTopOf="@+id/button2"
  55. app:layout_constraintVertical_bias="1.0"
  56. app:layout_constraintHorizontal_bias="0.509" />
  57. <Button
  58. android:id="@+id/button4"
  59. android:layout_width="0dp"
  60. android:text="执行测试"
  61. android:layout_height="48dp"
  62. tools:layout_constraintRight_creator="1"
  63. tools:layout_constraintBottom_creator="1"
  64. android:layout_marginStart="25dp"
  65. app:layout_constraintBottom_toBottomOf="parent"
  66. android:layout_marginEnd="25dp"
  67. app:layout_constraintRight_toRightOf="parent"
  68. tools:layout_constraintLeft_creator="1"
  69. android:layout_marginBottom="139dp"
  70. app:layout_constraintLeft_toLeftOf="parent"
  71. app:layout_constraintHorizontal_bias="0.68" />
  72. <EditText
  73. android:id="@+id/text1"
  74. android:layout_width="0dp"
  75. android:layout_height="60dp"
  76. android:layout_marginStart="25dp"
  77. tools:layout_constraintTop_creator="1"
  78. tools:layout_constraintRight_creator="1"
  79. tools:layout_constraintBottom_creator="1"
  80. app:layout_constraintBottom_toBottomOf="@+id/button1"
  81. android:layout_marginEnd="25dp"
  82. app:layout_constraintRight_toRightOf="parent"
  83. android:layout_marginTop="37dp"
  84. tools:layout_constraintLeft_creator="1"
  85. android:layout_marginBottom="48dp"
  86. app:layout_constraintLeft_toLeftOf="parent"
  87. app:layout_constraintTop_toTopOf="parent"
  88. app:layout_constraintVertical_bias="0.0" />
  89. <EditText
  90. android:id="@+id/text2"
  91. android:layout_width="0dp"
  92. android:layout_height="60dp"
  93. android:layout_marginEnd="25dp"
  94. android:layout_marginStart="25dp"
  95. tools:layout_constraintTop_creator="1"
  96. tools:layout_constraintRight_creator="1"
  97. tools:layout_constraintBottom_creator="1"
  98. app:layout_constraintBottom_toBottomOf="@+id/button2"
  99. app:layout_constraintRight_toRightOf="parent"
  100. android:layout_marginTop="58dp"
  101. tools:layout_constraintLeft_creator="1"
  102. android:layout_marginBottom="55dp"
  103. app:layout_constraintLeft_toLeftOf="parent"
  104. app:layout_constraintTop_toTopOf="@+id/button1" />
  105. <TextView
  106. android:id="@+id/text3"
  107. android:text=" 暗淡"
  108. android:layout_width="47dp"
  109. android:layout_height="27dp"
  110. tools:layout_constraintBottom_creator="1"
  111. android:layout_marginStart="16dp"
  112. app:layout_constraintBottom_toBottomOf="parent"
  113. tools:layout_constraintLeft_creator="1"
  114. android:layout_marginBottom="-5dp"
  115. app:layout_constraintLeft_toLeftOf="parent"
  116. android:layout_marginLeft="16dp" />
  117. </android.support.constraint.ConstraintLayout>

Main的class

  1. package com.example.prize.mydemo;
  2. import android.content.Intent;
  3. import android.net.Uri;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.util.Log;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.EditText;
  10. public class MainActivity extends AppCompatActivity {
  11. public static String [] PhoneAndTime = new String[2];
  12. @Override
  13. protected void onCreate(Bundle savedInstanceState) {
  14. //初始化界面
  15. super.onCreate(savedInstanceState);
  16. setContentView(R.layout.activity_main);
  17. // 写入号码
  18. //find按键
  19. Button SetPhone = (Button)findViewById(R.id.button1);
  20. //创建按键监听
  21. SetPhone.setOnClickListener(new View.OnClickListener(){
  22. @Override
  23. public void onClick(View view) {
  24. //获取EditText
  25. EditText phoneText = (EditText)findViewById(R.id.text1);
  26. PhoneAndTime[0] = String.valueOf(phoneText.getText());
  27. Log.e("Demo1","号码是:"+PhoneAndTime[0]);
  28. Log.e("Demo1","点击写入号码");
  29. }
  30. });
  31. // 重新写入号码
  32. /*
  33. Button ClearPhone = (Button)findViewById(R.id.button2);
  34. ClearPhone.setOnClickListener(new View.OnClickListener(){
  35. @Override
  36. public void onClick(View view) {
  37. EditText PhoneText = (EditText)findViewById(R.id.text2);
  38. PhoneText.setText("");
  39. PhoneAndTime[1] = String.valueOf(PhoneText.getText());
  40. Log.e("Demo1","点击重新写入号码");
  41. }
  42. });
  43. */
  44. //写入次数
  45. Button SetTime = (Button)findViewById(R.id.button2);
  46. SetTime.setOnClickListener(new View.OnClickListener() {
  47. @Override
  48. public void onClick(View view) {
  49. EditText timetext = (EditText)findViewById(R.id.text2) ;
  50. PhoneAndTime [1] = timetext.getText().toString();
  51. Log.e("Demo1","写入次数是:"+PhoneAndTime[1]);
  52. Log.e("Demo1","点击写入次数");
  53. }
  54. });
  55. //重新写入
  56. Button ClearTime = (Button)findViewById(R.id.buuton3);
  57. ClearTime.setOnClickListener(new View.OnClickListener() {
  58. @Override
  59. public void onClick(View view) {
  60. EditText phoneText = (EditText)findViewById(R.id.text1);
  61. EditText timetext = (EditText)findViewById(R.id.text2) ;
  62. phoneText.setText("");
  63. timetext.setText("");
  64. PhoneAndTime[0] = "";
  65. PhoneAndTime[1] = "";
  66. Log.e("Demo1","点击重新写入");
  67. }
  68. });
  69. //执行测试
  70. Button Run = (Button)findViewById(R.id.button4);
  71. Run.setOnClickListener(new View.OnClickListener() {
  72. @Override
  73. public void onClick(View view) {
  74. //new 新的Intent
  75. Intent data = new Intent(MainActivity.this,Demo_1.class);
  76. //用Bundle 携带数组
  77. Bundle bundle = new Bundle();
  78. bundle.putStringArray("phone_data",PhoneAndTime);
  79. //将 data Intent 添加Bundle
  80. data.putExtras(bundle);
  81. startActivity(data);
  82. Log.e("Demo1","点击执行测试");
  83. }
  84. });
  85. }
  86. }

执行拨号的后台 XML

  1.  
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent"
  7. tools:context="com.example.prize.mydemo.Demo_1">
  8. <TextView
  9. android:layout_width="wrap_content"
  10. android:layout_height="wrap_content"
  11. android:text="拨号"
  12. />
  13. </android.support.constraint.ConstraintLayout>

执行拨号的后台 class

  1.  
  1. package com.example.prize.mydemo;
  2. import android.content.Intent;
  3. import android.content.IntentSender;
  4. import android.net.Uri;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.util.Log;
  8. import android.widget.Toast;
  9. public class Demo_1 extends AppCompatActivity {
  10. @Override
  11. protected void onResume() {
  12. super.onResume();
  13. Intent intentdata = getIntent();
  14. Bundle bundle = this.getIntent().getExtras();
  15. String [] data = bundle.getStringArray("phone_data");
  16. Intent intent2 = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+data[0]));
  17. Log.e("Demo1","正在拨号");
  18. int time = Integer.parseInt(data[1]);
  19. for(int i=0;i<time;i++) {
  20. try {
  21. startActivity(intent2);
  22. Toast.makeText(Demo_1.this,"这是第:"+i+"拨号",Toast.LENGTH_SHORT).show();
  23. } catch (Exception e) {
  24. e.printStackTrace();
  25. Log.e("Demo1", "异常");
  26. }
  27. try {
  28. Log.e("Demo1","正在通话,等待120秒");
  29. Thread.sleep(120000);
  30. Log.e("Demo1","等待结束");
  31. } catch (InterruptedException e) {
  32. e.printStackTrace();
  33. Log.e("Demo1", "异常2");
  34. }
  35. }
  36. Log.e("Demo1","拨号循环已经跳出");
  37. Toast.makeText(Demo_1.this,"测试完成",Toast.LENGTH_SHORT).show();
  38. finish();
  39. }
  40. }

自写-自动拨号测试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. hadoop需要哪些技术支持

    hadoop是一个开源软件框架,可安装在一个商用机器集群中,使机器可彼此通信并协同工作,以高度分布式的方式共同存储和处理大量数据.最初,Hadoop 包含以下两个主要组件:Hadoop Distrib ...

  2. TransportClient 新建index,mappings dynamic_templates。

    public void createIndex(TransportClient client, String index){ CreateIndexRequest request = new Crea ...

  3. SourceInsight宏插件1(非常好用,强力推荐)

    对于一直使用sourceinsight编辑C/C++代码的工程师们,sourceinsight是一个非常好用的编辑工具可以任意定位,跳转,回退,本人一直使用该工具做C/C++开发,sourceinsi ...

  4. LINUX下PHP网页生成快照(截屏)(xvfb and wkhtmltoimage)

    经测试,可以使用 利用php截屏或实现网页快照我们需要用一个工具:xvfb and wkhtmltoimagek哦,这个工具目前只能在linux系统中使用,下面有兴趣的朋友可进入参考. 在做旅游攻略时 ...

  5. 【java】break,continue和return区别

    break:适用于switch和loop continue:只适用于loop 两者都可以通过给循环加标签来控制跳出,如下例所示 class BreakDemo { public static void ...

  6. DRP端口描述

    DRP端口描述 1.信息来源 2.端口描述

  7. oracle--合并行数据

    select to_char(wmsys.wm_concat(patname)) as WaitPatientName from (SELECT * FROM (SELECT ROW_NUMBER() ...

  8. tomcat整体架构

    1.背景 Tomcat作为JavaWeb领域的Web容器,目前在我们淘宝也使用的也非常广泛,现在基本上所有线上业务系统都是部署在Tomcat上.为了对平时开发的Web系统有更深入的理解以及出于好奇心对 ...

  9. 记录一次OOM分析过程

    工具: jstat jmap jhat 1.jstat查看gc情况 S0C.S1C.S0U.S1U:Survivor 0/1区容量(Capacity)和使用量(Used) EC.EU:Eden区容量和 ...

  10. PAT 乙级 1026 程序运行时间(15) C++版

    1026. 程序运行时间(15) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 要获得一个C语言程序的运行时间, ...