PowerManager使用執行個體1(下)

來源:互聯網
上載者:User

檔案2 layout\main.xml:

<?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"    >        <Button    android:id="@+id/Button0" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>    <Button    android:id="@+id/Button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button><Buttonandroid:id="@+id/Button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button><Buttonandroid:id="@+id/Button3" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button><Buttonandroid:id="@+id/Button4" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button><Buttonandroid:id="@+id/Button5" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="horizontal"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    ><Buttonandroid:id="@+id/Button6" android:text="@string/sleep"android:layout_width="wrap_content" android:layout_height="wrap_content"></Button><Buttonandroid:id="@+id/Button7" android:text="@string/reboot"android:layout_width="wrap_content" android:layout_height="wrap_content"></Button></LinearLayout><Buttonandroid:id="@+id/Button8" android:text="@string/userActivity"android:layout_width="wrap_content" android:layout_height="wrap_content"></Button></LinearLayout>檔案3 values\strings.xml:<?xml version="1.0" encoding="utf-8"?><resources>    <string name="hello">Hello World, MainActivity!</string>    <string name="app_name">PowerMangerSample</string>     <string name="acquire_PARTIAL">acquire PARTIAL_WAKE_LOCK</string>     <string name="release_PARTIAL">release PARTIAL_WAKE_LOCK</string>     <string name="acquire_SCREEN_DIM">acquire SCREEN_DIM_WAKE_LOCK</string>     <string name="release_SCREEN_DIM">release SCREEN_DIM_WAKE_LOCK</string>     <string name="acquire_SCREEN_BRIGHT">acquire SCREEN_BRIGHT_WAKE_LOCK</string>     <string name="release_SCREEN_BRIGHT">release SCREEN_BRIGHT_WAKE_LOCK</string>     <string name="acquire_FULL_WAKE_LOCK">acquire FULL_WAKE_LOCK_WAKE_LOCK</string>     <string name="release_FULL_WAKE_LOCK">release FULL_WAKE_LOCK_WAKE_LOCK</string>     <string name="combineFlag0">combine with ACQUIRE_CAUSES_WAKEUP</string>     <string name="notCombineFlag0">not combine with ACQUIRE_CAUSES_WAKEUP</string>     <string name="combineFlag1">combine with ON_AFTER_RELEASE</string>     <string name="notCombineFlag1">not combine with ON_AFTER_RELEASE</string>     <string name="sleep">go sleep</string>     <string name="reboot">reboot</string>     <string name="userActivity">userActivity</string></resources>檔案4 values\ids.xml:<resources>    <item type="id" name="StateKey" />    <item type="id" name="TextTurnOnKey" />    <item type="id" name="TextTurnOffKey" /></resources>檔案5 AndroidManifest.xml:<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"      package="com.teleca.robin"      android:versionCode="1"      android:versionName="1.0">    <application android:icon="@drawable/icon" android:label="@string/app_name">        <activity android:name=".MainActivity"                  android:label="@string/app_name">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>
    </application>    <uses-sdk android:minSdkVersion="8" /><uses-permission android:name="android.permission.WAKE_LOCK" /><uses-permission android:name="android.permission.DEVICE_POWER"/><uses-permission android:name="android.permission.REBOOT"/></manifest> 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.