Advertising (This ad goes away for registered users. You can Login or Register)

Android App Force closed when building an AlertDialog

Programming for your favorite smartphone or tablet? Post here
User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Android App Force closed when building an AlertDialog

Post by m0skit0 » Thu Sep 01, 2011 1:08 pm

Code: Select all

public class Bid extends Activity
:?:
Advertising
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

failbit
Posts: 48
Joined: Fri Apr 08, 2011 1:43 pm

Re: Android App Force closed when building an AlertDialog

Post by failbit » Thu Sep 01, 2011 1:34 pm

if I don't let Bid extend Activity I can't use the methods getString() to get the Strings out of my strings.xml file.
EDIT: It works!!! I just had to pass the whole Activity to AlertDialog.Builder. I think this is not an optimated solution but better than nothing. :D
Advertising
MIPS: Misleading Information to Promote Sales
Play Skat on your PSP:
viewtopic.php?f=26&t=5085

User avatar
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: Android App Force closed when building an AlertDialog

Post by m0skit0 » Fri Sep 02, 2011 7:08 am

failbit wrote:if I don't let Bid extend Activity I can't use the methods getString() to get the Strings out of my strings.xml file
I don't suggest you having more than one Activity if you don't know what you're doing. You can either pass the MobileSkatActivity to the Bid class to handle that calls or just pass to Bid class the data it needs from MobileSkatActivity. I insist: you should not extend from Activity unless absolutely required (which is not your case).
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"

failbit
Posts: 48
Joined: Fri Apr 08, 2011 1:43 pm

Re: Android App Force closed when building an AlertDialog

Post by failbit » Fri Sep 02, 2011 12:14 pm

I know that this is not the best programming-style so I rewrote a bit of my code. I have now a public static variable in MobileSkatActivity which contains the whole Activity. So I can use this Object to get my Strings and to pass it to the AlertDialog.Builder. So my Bid class doesn't extend Activity anymore. But I think there are a few things to optimate. But the most important thing is that I can continue working now. :)
MIPS: Misleading Information to Promote Sales
Play Skat on your PSP:
viewtopic.php?f=26&t=5085

Post Reply

Return to “Programming”