下载地址:
http://static.apk.hiapk.com/html/2012/06/614613.html
package caipiao3d.co.cc;
import java.util.Arrays;
import java.util.Timer;
import java.util.TimerTask;
import net.miidi.credit.MiidiCredit;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Typeface;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class caipiaoActivity extends Activity {
private SensorManager sensorMgr;
private int x, y, z;
private LinearLayout mLinearLayout;
private TextView mTextView1;
private TextView mTextView2;
private TextView mTextView3;
private Button mButton1;
MediaPlayer mediaPlayer;
void yin() {
mediaPlayer = MediaPlayer.create(caipiaoActivity.this, R.raw.back3);
mediaPlayer.setLooping(false);
mediaPlayer.start();
}
void loveyou() {
int[] red3 = new int[5];
String a3 = "";
for (int i = 0; i < 5; i++) {
red3[i] = ((int) (Math.random() * 9 + 0));
// char b = (char) (Math.random() * 20 + 'a');
// a = a+" "+String.valueOf(b);
}
Arrays.sort(red3);
for (int i = 0; i < 5; i++)
{
a3 = a3 + " " + red3[i];
mTextView2.setText(a3);
}
int[] red2 = new int[3];
String a2 = "";
for (int i = 0; i < 3; i++) {
red2[i] = ((int) (Math.random() * 9 + 0));
// char b = (char) (Math.random() * 20 + 'a');
// a = a+" "+String.valueOf(b);
}
Arrays.sort(red2);
for (int i = 0; i < 3; i++)
{
a2 = a2 + " " + red2[i];
mTextView1.setText(a2);
}
int[] red4 = new int[5];
String a4 = "";
for (int i = 0; i < 5; i++) {
red4[i] = ((int) (Math.random() * 9 + 0));
// char b = (char) (Math.random() * 20 + 'a');
// a = a+" "+String.valueOf(b);
}
Arrays.sort(red4);
for (int i = 0; i < 5; i++)
{
a4 = a4 + " " + red4[i];
mTextView3.setText(a4);
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
MiidiCredit.init(caipiaoActivity.this, "4859", "e1etrgkzzuj9lqgw",
false);
setContentView(R.layout.main);
mLinearLayout = (LinearLayout) findViewById(R.id.linearlayout1);
sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);
mTextView1 = (TextView) findViewById(R.id.tv1);
mTextView2 = (TextView) findViewById(R.id.tv2);
mTextView3 = (TextView) findViewById(R.id.tv3);
final TextView mTextView0 = (TextView) findViewById(R.id.textview0);
Typeface typeFace = Typeface.createFromAsset(getAssets(),
"fonts/caiyun.ttf");
mTextView0.setTypeface(typeFace);
View toastRoot = getLayoutInflater().inflate(R.layout.toast, null);
final Toast toast = new Toast(getApplicationContext());
toast.setView(toastRoot);
TextView tv = (TextView) toastRoot.findViewById(R.id.TextViewInfo);
tv.setText(" 选号进行成功!\n\n 祝君中500万大奖!\n");
mButton1 = (Button) findViewById(R.id.button01);
mButton1.setTypeface(typeFace);
SensorEventListener sensorEventListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent e) {
// TODO Auto-generated method stub
x = (int) e.values[SensorManager.DATA_X];
y = (int) e.values[SensorManager.DATA_Y];
z = (int) e.values[SensorManager.DATA_Z];
if (x > 7 && y > 6 && z < 8) {
loveyou();
yin();
// Toast.makeText(caipiaoActivity.this,
// " 选号成功!!!\n\n祝君中500万大奖!\n", 2000).show();
toast.show();
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
};
Sensor sensor = sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);// .SENSOR_ACCELEROMETER);
sensorMgr.registerListener(sensorEventListener, sensor,
SensorManager.SENSOR_DELAY_GAME /* SENSOR_DELAY_GAME */);
mButton1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
yin();
loveyou();
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
SubMenu subMenu = menu.addSubMenu(0, 1, 0, "关于");
SubMenu subMenu2 = menu.addSubMenu(0, 2, 0, "退出");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
if (item.getItemId() == 1) {
AlertDialog.Builder builder = new Builder(caipiaoActivity.this);
builder.setTitle("福彩3D,体彩排列软件信息");
builder.setMessage(R.string.about);
builder.create().show();
} else {
mLinearLayout.startAnimation(new TVOffAnimation());
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
android.os.Process.killProcess(android.os.Process.myPid());
}
}, 1000);
}
return true;
}
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
Intent i = new Intent(Intent.ACTION_MAIN);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addCategory(Intent.CATEGORY_HOME);
startActivity(i);
super.onBackPressed();
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
mediaPlayer.release();
}
}