Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid alarm not working
    primarykey
    data
    text
    <p>I tried simple alarm by the help of one example in android... its running good but i can not get alarm to the set the time </p> <p>Error in logcat :</p> <pre><code>04-08 00:17:52.016: DEBUG/SntpClient(67): request time failed: java.net.SocketException: Address family not supported by protocol </code></pre> <p><strong>alarm.java</strong></p> <pre><code>public class Alarm extends Activity { DateFormat fmtDateAndTime=DateFormat.getDateTimeInstance(); TextView dateAndTimeLabel; Calendar dateAndTime=Calendar.getInstance(); Button Alarm; Alarm instance; Toast mToast=null; DatePickerDialog.OnDateSetListener d=new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { dateAndTime.set(Calendar.YEAR, year); dateAndTime.set(Calendar.MONTH, monthOfYear); dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth); } }; TimePickerDialog.OnTimeSetListener t=new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay,int minute) { dateAndTime.set(Calendar.HOUR_OF_DAY, hourOfDay); dateAndTime.set(Calendar.MINUTE, minute); view.setCurrentHour(Calendar.HOUR_OF_DAY); } }; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); instance = this; Button btn=(Button)findViewById(R.id.Date); Alarm = (Button)findViewById(R.id.Alarm); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new DatePickerDialog(Alarm.this,d, dateAndTime.get(Calendar.YEAR), dateAndTime.get(Calendar.MONTH), dateAndTime.get(Calendar.DAY_OF_MONTH)).show(); } }); btn=(Button)findViewById(R.id.time); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new TimePickerDialog(Alarm.this,t, dateAndTime.get(Calendar.HOUR_OF_DAY), dateAndTime.get(Calendar.MINUTE), true).show(); } }); Alarm.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { Intent intent = new Intent(instance, OnetimeAlarmReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(instance,0, intent, 0); dateAndTime.add(Calendar.SECOND, 5); long timeSet = dateAndTime.getTimeInMillis(); AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, timeSet, sender); if (mToast != null) { mToast.cancel(); } mToast = Toast.makeText(instance, "Alarm Set for " + dateAndTime.getTime(), Toast.LENGTH_LONG); mToast.show(); } }); } } </code></pre> <p><strong>OnetimeAlarmReceiver.java</strong></p> <pre><code> public class OnetimeAlarmReceiver extends Service{ @Override public void onCreate() { super.onCreate(); Builder builder = new Builder(this); builder.setMessage("Started").create().show(); Log.d("Value ", "Service Started"); } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Builder builder = new Builder(this); builder.setMessage("Started").create().show(); Log.d("Value ", "Service Started"); } @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } } </code></pre> <p><strong>manifest:</strong></p> <pre><code>&lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt; &lt;activity android:name=".Alarm" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name =".OnetimeAlarmReceiver"&gt; </code></pre> <p> </p> <p>where i did mistake Any one can help thank you </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload