phonetest
来源:互联网 发布:淘宝最常见韩国模特 编辑:程序博客网 时间:2024/05/20 05:53
package com.hyf.service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class RecordisBootReciever extends BroadcastReceiver {
public static int shutdowntimes;
public static int startuptimes;
private static final String TAG="RecordShutdownTimes";
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())){
startuptimes++;
}
shutdowntimes=(shutdowntimes==0)?0:startuptimes-1;
}
}
------------------------------------------------------------------
package com.hyf.test;
import com.hyf.service.RecordisBootReciever;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class ShutDownTimesActivity extends Activity {
private TextView startuptimes;
private TextView shutdowntimes;
Button startuptimesButton;
Button shutdowntimesButton;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startuptimesButton=(Button)findViewById(R.id.startuptimesButton);
shutdowntimesButton =(Button)findViewById(R.id.shutdowntimesButton);
startuptimes= (TextView)findViewById(R.id.startuptimes);
shutdowntimes=(TextView)findViewById(R.id.shutdowntimes);
startuptimesButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startuptimes.setText(RecordisBootReciever.startuptimes);
setContentView(R.layout.main);
}
});
shutdowntimesButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
shutdowntimes.setText(RecordisBootReciever.shutdowntimes);
setContentView(R.layout.main);
}
});
}
}
---------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<Button
android:id="@+id/startuptimesButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/startuptimesButton"
/>
<TextView
android:id="@+id/startuptimes"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:background="#aaaa00"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<Button
android:id="@+id/shutdowntimesButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/shutdowntimesButton"
/>
<TextView
android:id="@+id/shutdowntimes"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:background="#aaaa00"
/>
</LinearLayout>
</LinearLayout>
- phonetest
- XML编程
- 交互原型设计软件 Axure RP Pro 5 中文教程《转载》
- int 转换成byte 数字
- 复习1:bool类型和char数组
- java.lang.IllegalStateException: Content has been
- phonetest
- PHPMYADMIN简明安装教程 及 常用配置选项
- vc++ 菜单处理
- shell值班问题。
- C++ 工程实践(2):不要重载全局 ::operator new()
- 光源选型二(光源颜色组合、滤光及波长特性)
- Zen cart 加载流程
- 在 Gradle 脚本中处理Manifest: ClassPath
- DEDECMS 网站迁移教你一招