Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android報警功能,報警鈴音,手機開始震動

Android報警功能,報警鈴音,手機開始震動

編輯:關於Android編程

公司項目需求,需要給軟件加入報警功能,

點擊手繪的報警圖標,開始震動,並且發出報警鈴音,

使用了layerlist,drawable,Vibrator,soundpool



\


<喎?/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+PGJyPgo8L3A+CjxwPnB1YmxpYyBjbGFzcyBTb3NNYWluQWN0aXZpdHkgZXh0ZW5kcyBCYXNlQWN0aXZpdHl7PGJyPgo8YnI+Cjxicj4KcHJpdmF0ZSBUZXh0VmlldyBzb3NUdjEsc29zVHYyLHNvc1R2Mzs8YnI+CiAgICBwcml2YXRlIGludCBibHVlQ29sb3IgLCB3aGl0ZUNvbG9yLHRyYW5zcGFyZW50Owo8YnI+CiAgICA8YnI+CiAgICBwcml2YXRlIFZpYnJhdG9yIHZpYnJhdG9yOzxicj4KICAgIHByaXZhdGUgU291bmRQb29sIHNvdW5kUG9vbDs8YnI+CiAgICBpbnQgaGl0Ozxicj4KICAgIEBPdmVycmlkZTxicj4KcHJvdGVjdGVkIHZvaWQgb25DcmVhdGUoQnVuZGxlIHNhdmVkSW5zdGFuY2VTdGF0ZSkgezxicj4KLy8gVE9ETyBBdXRvLWdlbmVyYXRlZCBtZXRob2Qgc3R1Yjxicj4Kc3VwZXIub25DcmVhdGUoc2F2ZWRJbnN0YW5jZVN0YXRlKTs8YnI+CiAgIHNldENvbnRlbnRWaWV3KFIubGF5b3V0LmFjdGl2aXR5X3Nvcyk7PGJyPgogICA8YnI+CiAgIHNvc1R2MSA9IChUZXh0VmlldylmaW5kVmlld0J5SWQoUi5pZC5zb3N0djEpOzxicj4KICAgc29zVHYyID0oVGV4dFZpZXcpZmluZFZpZXdCeUlkKFIuaWQuc29zdHYyKTs8YnI+CiAgIHNvc1R2MyA9KFRleHRWaWV3KWZp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AgICB9PGJyPgogICAgPGJyPgogICAgcHJpdmF0ZSB2b2lkIGJ0blNlbGVjdGVkMigpezxicj4KICAgIERyYXdhYmxlIGJhY2sxID0gZ2V0UmVzb3VyY2VzKCkuZ2V0RHJhd2FibGUoUi5kcmF3YWJsZS5idG5fc2FmZXR5X2xlZnRzaGFwZSk7PGJyPgogICAgc29zVHYxLnNldEJhY2tncm91bmREcmF3YWJsZShiYWNrMSk7PGJyPgpzb3NUdjEuc2V0VGV4dENvbG9yKGJsdWVDb2xvcik7PGJyPgpzb3NUdjIuc2V0QmFja2dyb3VuZFJlc291cmNlKHRyYW5zcGFyZW50KTs8YnI+CnNvc1R2Mi5zZXRUZXh0Q29sb3Iod2hpdGVDb2xvcik7PGJyPgogICAgICA8YnI+CiAgICAgfTxicj4KPGJyPgp9PGJyPgo8L3A+CjxwPjxicj4KPC9wPgo8cD5hY3Rpdml0eV9zb3MueG1sPC9wPgo8cD48P3htbCB2ZXJzaW9uPQ=="1.0" encoding="utf-8"?>
xmlns:my="http://schemas.android.com/apk/res/com.seable.withome"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >


android:id="@+id/TitleBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
my:titleName="智慧家園" />


android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="50dp"
android:padding="10dp" >


android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/btn_safety_back1"
android:orientation="horizontal" >


android:id="@+id/sostv1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="10dp"
android:text="緊急救援"
android:textSize="@dimen/txt_20"
android:textColor="@color/white" />


android:id="@+id/sostv2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/btn_safety_right"
android:gravity="center"
android:padding="10dp"
android:text="對講報警"
android:textSize="@dimen/txt_20"
android:textColor="@color/bluetext" />





android:id="@+id/sostv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="100dp"
android:background="@drawable/btn_sos_main"
android:gravity="center"
android:paddingTop="120dp"
android:text="緊急報警"
android:textSize="25sp"
android:textColor="@android:color/white" />






csdn下載 http://download.csdn.net/detail/kan1kan5/8217051

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved