Android 4.1打开相机(自己写的压力测试APK)
发布日期:2021-06-30 18:52:30 浏览次数:3 分类:技术文章

本文共 2109 字,大约阅读时间需要 7 分钟。

JAVA:
package com.example.cameratest;import android.support.v7.app.ActionBarActivity;import android.support.v4.app.Fragment;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.view.LayoutInflater;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.view.ViewGroup;import android.widget.Button;import android.provider.MediaStore;public class MainActivity extends ActionBarActivity {	private Button button1;    private int TIME = 1000;  		@Override	protected void onCreate(Bundle savedInstanceState) {		super.onCreate(savedInstanceState);		setContentView(R.layout.fragment_main);		handler.postDelayed(runnable, TIME); //每隔1s执行 		button1=(Button)findViewById(R.id.button1qqqq);		button1.setOnClickListener(new Button.OnClickListener(){			 public void onClick(View v)			 {				 System.out.println("finish.$$$$$$$$$$$$$$$$$$$$$$$"); 				 handler.removeCallbacks(runnable);				 //finish();				 System.exit(0);			 }	});	}	private static int k=0;	Handler handler = new Handler();      Runnable runnable = new Runnable() {               @Override          public void run() {              // handler自带方法实现定时器              try {                  handler.postDelayed(this, TIME);                  //tvShow.setText(Integer.toString(i++));                  System.out.println("do...");                 k++;                if(k==5){                	Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);                	startActivityForResult(intent,0);                	System.out.println("do...33333");                 }                if(k==12)                {                	System.out.println("do..6666.");                 	 Intent intent=new Intent();                     intent.setClass(MainActivity.this,MainActivity.class);                    startActivity(intent);                	k=0;                }            } catch (Exception e) {                  // TODO Auto-generated catch block                  e.printStackTrace();                  System.out.println("exception...");              }          }      };  }

XML:

转载地址:https://linus.blog.csdn.net/article/details/42151447 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:怎样在Linux驱动中创建proc节点(示例)
下一篇:adb shell logcat 输出对应APK的日志

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月22日 02时24分52秒