Re: [android-beginners] Problems using AlertDialog in a onReceive() method
On Wed, Jul 28, 2010 at 8:26 PM, Brad Taylor wrote: > Would I create a whole new > Activity class that creates the AlertDialog. No, you would create a whole new Activity class that displays what you want to display. If you want it to look like an AlertDialog, add the following attribute to your element in the manifest: android:theme="@android:style/Theme.Dialog" http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme > Then in my receiver class call the startActivity()? Yes. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 2.9 Available! -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Problems using AlertDialog in a onReceive() method
Thanks for the quick reply Mark. I am unsure what you mean by using a dialog-themed Activity and startActivity(). I have added a Alarm in my mainclass // Schedule the alarm! AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); if (isOn) { // Set alarm am.setRepeating(AlarmManager.RTC_WAKEUP, pickedDateAndTime.getTimeInMillis(), 6, sender); } else { // Cancel alarm am.cancel(sender); Toast.makeText(AlarmClock.this, "Alarm cancelled", Toast.LENGTH_LONG).show(); } Then in my Manifest I added my Reciever Class in like this Then I have the Receiver Code below. I am unsure how to go about adding a dialog-themed Activity and startActivity. Would I create a whole new Activity class that creates the AlertDialog. Then in my receiver class call the startActivity()? Once again thanks! --Brad On Wed, Jul 28, 2010 at 4:39 PM, Mark Murphy wrote: > On Wed, Jul 28, 2010 at 7:24 PM, Brad Taylor wrote: > > I new to the SDK and have intermediate Java skills and I am having an > issue > > with adding an AlertDialog to a Receiver I have created. > > Try using a dialog-themed Activity and startActivity() instead. > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://github.com/commonsguy > http://commonsware.com/blog | http://twitter.com/commonsguy > > _Android Programming Tutorials_ Version 2.9 Available! > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Problems using AlertDialog in a onReceive() method
On Wed, Jul 28, 2010 at 7:24 PM, Brad Taylor wrote: > I new to the SDK and have intermediate Java skills and I am having an issue > with adding an AlertDialog to a Receiver I have created. Try using a dialog-themed Activity and startActivity() instead. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 2.9 Available! -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
[android-beginners] Problems using AlertDialog in a onReceive() method
Hello Everyone, I new to the SDK and have intermediate Java skills and I am having an issue with adding an AlertDialog to a Receiver I have created. The application is a basic alarm clock and I am using the following code as the receiving class. I want to use an AlertDialog instead of Toast so that I can have a snooze and an off button. It seems to be creating the AlertBox fine but when I try to show it the program blows up. Below is the code I am trying to use, any help is much appreciated! Thanks, Brad public class RepeatingAlarm extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { try { // Do something when alarm goes off AlertDialog.Builder alertbox = new AlertDialog.Builder(context); alertbox.setMessage("Its time to get up"); // add a neutral button to the alert box and assign a click listener alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() { // click listener on the alert box public void onClick(DialogInterface arg0, int arg1) { // the button was clicked do something } }); alertbox.show(); } catch (Exception e) { Log.e("AlarmClock.java", "ERROR: ", e); } MediaPlayer mp = MediaPlayer.create(context, R.raw.duck); mp.start(); } } -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en