fork(1) download
  1. package com.example.alarm;
  2.  
  3. import java.util.Calendar;
  4.  
  5. import android.app.Activity;
  6. import android.app.AlarmManager;
  7. import android.app.PendingIntent;
  8. import android.content.BroadcastReceiver;
  9. import android.content.Context;
  10. import android.content.Intent;
  11. import android.content.IntentFilter;
  12. import android.os.Bundle;
  13. import android.util.Log;
  14.  
  15. public class AlarmActivity extends Activity {
  16. private BroadcastReceiver receiver = new BroadcastReceiver() {
  17. @Override
  18. public void onReceive(Context context, Intent intent) {
  19. String keyword1 = intent.getStringExtra("hogeID");
  20. Log.v("MainActivityID", keyword1);// 理想はこちらでアラーム後の値を拾いたい。
  21. }
  22. };
  23.  
  24. /** Called when the activity is first created. */
  25. @Override
  26. public void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.main);
  29. alarmtimeset();
  30.  
  31. IntentFilter filter = new IntentFilter();
  32. filter.addAction("com.example.action.ALARM");
  33. registerReceiver(receiver, filter);
  34. }
  35.  
  36. @Override
  37. protected void onDestroy() {
  38. super.onDestroy();
  39. unregisterReceiver(receiver);
  40. }
  41.  
  42. public void alarmtimeset() {
  43. Log.v("TEST", "アラームセット");
  44. for (int intc = 0; intc < 5; intc++) {
  45. Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class); // ReceivedActivityを呼び出すインテントを作成
  46. intent.putExtra("hogeID", "ID" + intc);
  47. intent.setType("Hoge" + intc);
  48. PendingIntent sender = PendingIntent.getBroadcast(AlarmActivity.this, 0, intent, 0); // ブロードキャストを投げるPendingIntentの作成
  49.  
  50. Calendar calendar = Calendar.getInstance(); // Calendar取得
  51. calendar.setTimeInMillis(System.currentTimeMillis()); // 現在時刻を取得
  52. // calendar.set(2013,9,7,10,50,0+intc*10);//時刻を手動で設定
  53. calendar.add(Calendar.SECOND, 10 * intc);
  54. AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); // AlramManager取得
  55. am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender); // AlramManagerにPendingIntentを登録
  56. }
  57. }
  58. }
  59.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:15: error: class AlarmActivity is public, should be declared in a file named AlarmActivity.java
public class AlarmActivity extends Activity {
       ^
Main.java:5: error: package android.app does not exist
import android.app.Activity;
                  ^
Main.java:6: error: package android.app does not exist
import android.app.AlarmManager;
                  ^
Main.java:7: error: package android.app does not exist
import android.app.PendingIntent;
                  ^
Main.java:8: error: package android.content does not exist
import android.content.BroadcastReceiver;
                      ^
Main.java:9: error: package android.content does not exist
import android.content.Context;
                      ^
Main.java:10: error: package android.content does not exist
import android.content.Intent;
                      ^
Main.java:11: error: package android.content does not exist
import android.content.IntentFilter;
                      ^
Main.java:12: error: package android.os does not exist
import android.os.Bundle;
                 ^
Main.java:13: error: package android.util does not exist
import android.util.Log;
                   ^
Main.java:15: error: cannot find symbol
public class AlarmActivity extends Activity {
                                   ^
  symbol: class Activity
Main.java:16: error: cannot find symbol
	private BroadcastReceiver receiver = new BroadcastReceiver() {
	        ^
  symbol:   class BroadcastReceiver
  location: class AlarmActivity
Main.java:26: error: cannot find symbol
	public void onCreate(Bundle savedInstanceState) {
	                     ^
  symbol:   class Bundle
  location: class AlarmActivity
Main.java:16: error: cannot find symbol
	private BroadcastReceiver receiver = new BroadcastReceiver() {
	                                         ^
  symbol:   class BroadcastReceiver
  location: class AlarmActivity
Main.java:27: error: cannot find symbol
		super.onCreate(savedInstanceState);
		^
  symbol:   variable super
  location: class AlarmActivity
Main.java:28: error: package R does not exist
		setContentView(R.layout.main);
		                ^
Main.java:31: error: cannot find symbol
		IntentFilter filter = new IntentFilter();
		^
  symbol:   class IntentFilter
  location: class AlarmActivity
Main.java:31: error: cannot find symbol
		IntentFilter filter = new IntentFilter();
		                          ^
  symbol:   class IntentFilter
  location: class AlarmActivity
Main.java:25: error: method does not override or implement a method from a supertype
	@Override
	^
Main.java:38: error: cannot find symbol
		super.onDestroy();
		^
  symbol:   variable super
  location: class AlarmActivity
Main.java:36: error: method does not override or implement a method from a supertype
	@Override
	^
Main.java:43: error: cannot find symbol
		Log.v("TEST", "???????");
		^
  symbol:   variable Log
  location: class AlarmActivity
Main.java:45: error: cannot find symbol
			Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class); // ReceivedActivity?????????????
			^
  symbol:   class Intent
  location: class AlarmActivity
Main.java:45: error: cannot find symbol
			Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class); // ReceivedActivity?????????????
			                    ^
  symbol:   class Intent
  location: class AlarmActivity
Main.java:45: error: cannot find symbol
			Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class); // ReceivedActivity?????????????
			                           ^
  symbol:   method getApplicationContext()
  location: class AlarmActivity
Main.java:45: error: cannot find symbol
			Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class); // ReceivedActivity?????????????
			                                                    ^
  symbol:   class AlarmReceiver
  location: class AlarmActivity
Main.java:48: error: cannot find symbol
			PendingIntent sender = PendingIntent.getBroadcast(AlarmActivity.this, 0, intent, 0); // ????????????PendingIntent???
			^
  symbol:   class PendingIntent
  location: class AlarmActivity
Main.java:48: error: cannot find symbol
			PendingIntent sender = PendingIntent.getBroadcast(AlarmActivity.this, 0, intent, 0); // ????????????PendingIntent???
			                       ^
  symbol:   variable PendingIntent
  location: class AlarmActivity
Main.java:54: error: cannot find symbol
			AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); // AlramManager??
			^
  symbol:   class AlarmManager
  location: class AlarmActivity
Main.java:54: error: cannot find symbol
			AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); // AlramManager??
			                   ^
  symbol:   class AlarmManager
  location: class AlarmActivity
Main.java:54: error: cannot find symbol
			AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); // AlramManager??
			                                                  ^
  symbol:   variable ALARM_SERVICE
  location: class AlarmActivity
Main.java:55: error: cannot find symbol
			am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender); // AlramManager?PendingIntent???
			       ^
  symbol:   variable AlarmManager
  location: class AlarmActivity
32 errors
stdout
Standard output is empty