This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// アクティビティからタイマーサービススタート | |
Intent intent = new Intent( mContext, TimerService.class ); | |
intent.putExtra( "counter", result ); | |
startService( intent ); | |
//呼び出されたServiceプログラムでTimerをスタートします。 | |
if ( timer != null ) | |
timer.cancel(); | |
timer = new Timer(); | |
final android.os.Handler handler = new android.os.Handler(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//インスタンス変数の定義 | |
SpeechRecognizer rec; | |
//onCreate()で変数にリスナーをセットする | |
// 音声認識 | |
rec = SpeechRecognizer.createSpeechRecognizer( getApplicationContext() ); | |
rec.setRecognitionListener( new speechListenerAdp() ); | |
//音声認識をスタートする | |
// SpeechRecognizer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SensorManager sensorMgr; | |
booleanhasSensor; | |
//センサーマネージャの取得 | |
sensorMgr = ( SensorManager ) getSystemService( SENSOR_SERVICE ); | |
hasSensor = false; | |
//センサマネージャへリスナーを登録 | |
//ここのTYPE_PROXIMITYというところを置き換えることで、様々なセンサの値が取得可能 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<menu | |
xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item | |
android:title="@string/menu_title_setting" | |
android:id="@+id/menu_setting" | |
android:orderInCategory="1" | |
android:icon="@android:drawable/ic_menu_preferences"></item> | |
<item | |
android:title="@string/menu_title_help" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//inflaterを使ってxmlリソースファイルを読み込んでメニューを作成する。 | |
@Override | |
publicboolean onCreateOptionsMenu( Menu menu ) { | |
super.onCreateOptionsMenu( menu ); | |
MenuInflater inflater = getMenuInflater(); | |
//インフレートしています | |
inflater.inflate( R.menu.option_menu, menu ); | |
returntrue; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
* プリファレンスの値を読み込む | |
* | |
*/ | |
privatevoid loadSetting() { | |
//自分で定義したプリファレンスファイルを使用することも出来ますが、デフォルトのプリファレンスを利用しています | |
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences( this ); | |
// アプリのバージョン情報 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> | |
<PreferenceCategory android:title="@string/pref_cattitle_sound"> | |
<ListPreference | |
android:title="@string/pref_title_sound" | |
android:summary="@string/pref_summary_sound" | |
android:key="@string/pref_key_sound" | |
android:entries="@array/entries" | |
android:entryValues="@array/entryValues" | |
android:dialogTitle="@string/pref_title_sound" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SettingActivity extends PreferenceActivity { | |
@Override | |
publicvoid onCreate( Bundle savedInstanceState ) { | |
super.onCreate( savedInstanceState ); | |
// XML で Preference を設定 | |
addPreferencesFromResource( R.xml.preference ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//インスタンス変数を宣言 | |
AudioManager am; | |
SeekBar ringVolSeekBar; | |
TextView ringVolText; | |
// アラーム音量 | |
am = ( AudioManager ) getSystemService( Context.AUDIO_SERVICE ); | |
//現在の音量を取得します | |
int ringVolume = am.getStreamVolume( AudioManager.STREAM_MUSIC ); // 音量の取得 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xmlversion="1.0"encoding="utf-8"?> | |
<manifestxmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.yochiyochi.android.UntouchableTimer" ←Javaパッケージ名、世界でたった一つであること。 | |
android:versionCode="6" ← マーケットにアップデートするたびにカウントアップするべき数 | |
android:versionName="1.0" ← アプリのバージョン(ここは自分で決める) | |
android:installLocation="preferExternal" > ← インストールする場所(SDカード優先) | |
<uses-sdkandroid:minSdkVersion="8"/> ← ターゲットのバージョンこれ以下の機種にはインストール出来ない | |
<uses-permissionandroid:name="android.permission.RECORD_AUDIO"/> ← 音声認識を使用する権限を与える。 |
OlderNewer