您的位置:首页 > 移动开发 > Android开发

Android开发里面怎么在画图的时候监测到一个特定的数值利用Intent调用发短消息啊

2017-01-01 02:43 309 查看
   

package com.android.cricle;

import android.app.Activity;

import android.content.Context;

import android.content.Intent;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.Canvas;

import android.graphics.Matrix;

import android.net.Uri;

import android.os.Bundle;

import android.util.AttributeSet;

import android.view.View;

import android.view.View.OnClickListener;

public class OilView extends View implements Runnable {

private float angel = 0;

private float  angelArray [] = {120,67,89,46,78,98,87,78,67,56,45,68,67,89,98,76,78,98,76,78,98,75};

private Matrix matrix;

private Bitmap needleBm;

private Bitmap oilBm;

private Bitmap bootBm;

public OilView(Context context, AttributeSet attrs) {

super(context, attrs);

// TODO Auto-generated constructor stub

init();

}

public OilView(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

// TODO Auto-generated constructor stub

init();

}

public OilView(Context context) {

super(context);

// TODO Auto-generated constructor stub

init();

}

private void init() {

matrix = new Matrix();

needleBm = BitmapFactory.decodeResource(getResources(),

R.drawable.info_rt_base_needle_);

bootBm = BitmapFactory.decodeResource(getResources(),

R.drawable.info_rt_base_needle_boot_);

oilBm = BitmapFactory.decodeResource(getResources(),

R.drawable.info_rt_ins_oil_);

new Thread(this).start();

}

@Override

protected void onDraw(Canvas canvas) {

// TODO Auto-generated method stub

super.onDraw(canvas);

matrix.reset();

canvas.drawBitmap(oilBm, 0, 0, null);

matrix.preTranslate( oilBm.getWidth() / 2-bootBm.getWidth()/2+3,

oilBm.getHeight() / 2 - bootBm.getHeight() / 2);

matrix.preRotate(angel, needleBm.getWidth()/2, needleBm.getHeight()/6);

canvas.drawBitmap(needleBm, matrix, null);

canvas.drawBitmap(bootBm, oilBm.getWidth() / 2 - bootBm.getWidth() / 2,

oilBm.getHeight() / 2 - bootBm.getHeight() / 2, null);

}

@Override

public void run() {

// TODO Auto-generated method stub

int i=0;

while (!Thread.currentThread().isInterrupted()) {

try {

Thread.sleep(300);

angel = angelArray[i];

 i++;

 i=i%angelArray.length;

} catch (InterruptedException e) {

Thread.currentThread().interrupt();

}

postInvalidate();

 if(angelArray[i]>110){

 

 Uri uri = Uri.parse("smsto:15881142025");    

Intent intent = new Intent(Intent.ACTION_SENDTO, uri);    

intent.putExtra("sms_body", "你好");    

      startActivity(intent);

 }

}

}

}


像这样



为什么会出错啊 !!

具体改什么做?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐