I want to make an app that has buttons that when pressed, plays a sound. How would I add the sounds, and then use the Line thing in IB to connect them to a button?
I posted this back in May on the [android-developers] Google Group. I never heard back and was not able to reproduce the problem until one of my students did last week. I figured I'd post it here and see if it rang any bells for anyone.
In one of my code samples, I have the following method:
static Cursor getAll(SQLiteDatabase db, String orderBy) {
return(db.rawQuery("SELECT * FROM restaurants "+orderBy, null));
}
When I run it, sporadically, I get this:
05-01 14:45:05.849: ERROR/AndroidRuntime(1145):
java.lang.IllegalStateException: attempt to acquire a reference on a
close SQLiteClosable
05-01 14:45:05.849: ERROR/AndroidRuntime(1145): at
android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:31)
05-01 14:45:05.849: ERROR/AndroidRuntime(1145): at
android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:56)
05-01 14:45:05.849: ERROR/AndroidRuntime(1145): at
android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
05-01 14:45:05.849: ERROR/AndroidRuntime(1145): at
android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:49)
05-01 14:45:05.849: ERROR/AndroidRuntime(1145): at
android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1118)
05-01 14:45:05.849: ERROR/AndroidRuntime(1145): at
android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1092)
05-01 14:45:05.849: ERROR/AndroidRuntime(1145): at
apt.tutorial.Restaurant.getAll(Restaurant.java:14)
This makes no sense to me. The database is definitely open. The
SQLiteClosable is the SQLiteQuery created by SQLiteQueryDriver, and I
see no evidence that there is an object pool or something going on here
that might explain how a "new" SQLiteClosable is already closed. The
fact that it is sporadic (meaning the same UI operations sometimes
trigger the exception, but not always) suggests some sort of pool, race
condition, or something...but I'm not sure where.
Thoughts?
Thanks!
UPDATE: The code in question is from the LunchList tutorials out of my Android Programming Tutorials book. It's a bit spread out and not terribly suitable for posting directly in SO. You can download the code for that book from the above link if you want to take a look at it. I do not recall exactly which edition of the tutorial the student was working on at the time, though it was in the Tutorial 12-Tutorial 16 range. I was mostly hoping to run across somebody who had tripped over this problem before and had a likely culprit. I'm fairly certain my database is open. Thanks again!
Hi, I purchased Amazing Slow Downer for iphone. It permits to change audio speed without changing pitch. Could someone please help me in finding the source code for obtaining such a function.
Thank you
Mauro
I am just wondering is there a way to convert nib/xib file to ojbective C code? I just want to find the equivalent code to the nib/xib file (I've tried nib2objc, seems the result is not what I am after).
Actually I want to compile this example
http://developer.apple.com/iphone/library/samplecode/TableSearch/index.html
without nib/xib file (I want it exactly the same with original), any idea about doing this?
i'd like to change sounds when tapping on an image and drag another image over several others.
it is not working properly: the "MoveImage" is not dragable, the tapping is working outside the "TouchImage" and the sounds do not change when tapping on it.
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if(((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_1.frame)))) {
[sound_E play];
}
if (((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_2.frame)))) {
[sound_F play];
}
if (((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_3.frame)))) {
[sound_D play];
}
if (((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_4.frame)))) {
[sound_Dis play];
}
}
(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (CGRectContainsPoint(myMoveImage.frame, location)){
CGPoint yLocation = CGPointMake(myMoveImage.center.x,location.y);
myMoveImage.center = yLocation;
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_1.frame)) {
E_NOTE.text = @"E";
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_2.frame)) {
F_NOTE.text = @"F";
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_3.frame)) {
D_NOTE.text = @"D";
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_4.frame)) {
Dis_NOTE.text = @"D#";
}
}
My iPhone simulator refuses to update the resources which I edit.
After doing a "Clean" and build, the new resources were installed. On the second run it reinstalled the old ones. I have no idea where it's getting them from.
Any suggestions?
If I try and release tempSeedsArray after seedsArray = tempSeedsArray , I get an EXEC_BAD_ACCESS, and Instruments shows that tempSeedsArray has been released twice. Here is my viewWillAppear method:
- (void)viewWillAppear:(BOOL)animated {
NSString *arrayFilePath = [[NSBundle mainBundle] pathForResource:@"SeedsArray" ofType:@"plist"];
NSLog(@"HIT!");
NSMutableArray *tempSeedsArray = [[NSMutableArray alloc] initWithContentsOfFile:arrayFilePath];
seedsArray = tempSeedsArray;
NSLog(@"%u", [seedsArray retainCount]);
[seedsArray sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
[super viewWillAppear:animated];
}
seedsArray is an NSMutableArray set as a nonatomic and a retain property, and is synthesised.
However, if I change seedsArray = tempSeedsArray to self.seedsArray = tempSeedsArray (or [self seedsArray] = tempSeedsArray etc.), I can release tempSeedsArray. Could someone please explain simply to me why this is, as I am very confused!
Thanks
I always take precautions regarding SQL INJECTION ATTACKS when data is saved between someone's iPhone and a remote database on the cloud.
But is it also necessary to do the same... when just saving data (using sqlite) from someone's cell phone, to a database that's just on their own phone?
What's the worse they can do? Delete their own data (or tables) on their own phone?
(If they really try hard enough.)
Thanks.
Hi
I am making a call to verifyReceipt to validate an in-app purchase but am getting a very strange response (the response is b)
The same code worked till some time back. But I stopped the app debugging while the trans was being verified at one point. From there on, the only response I get is b. I checked the code and it has nothing wrong. As I said, the same code worked till I stopped this trans mid-way.
Any idea what could be wrong?
Thanks.
hello
I've placed this code my didload method, to get a black Navigationbar.
rootTabBarController.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
rootTabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
its working fine, but when the user rearranges the Icons in the editmode, i'm getting a default blue navigation bar. Can anyone help me to avid this ?
btw: big thanks to the genius crowd!
I just add this methods in .h file :
- (IBAction)EditTable:(id)sender;
- (IBAction)DeleteButtonAction:(id)sender;
and in .m file :
(IBAction)DeleteButtonAction:(id)sender{
[tableList removeLastObject];
[Table reloadData];
}
(IBAction) EditTable:(id)sender{
if(self.editing)
{
[super setEditing:NO animated:NO];
[Table setEditing:NO animated:NO];
[Table reloadData];
[self.navigationItem.leftBarButtonItem setTitle:@"Edit"];
[self.navigationItem.leftBarButtonItem setStyle:UIBarButtonItemStylePlain];
}
else
{
[super setEditing:YES animated:YES];
[Table setEditing:YES animated:YES];
[Table reloadData];
[self.navigationItem.leftBarButtonItem setTitle:@"Done"];
[self.navigationItem.leftBarButtonItem setStyle:UIBarButtonItemStyleDone];
}
}
when I run the program and click the delete button (red button) the program is stop !
whats the problem ? please any help ?
hellow all, in xcode whenever we load a mapview ,it automaticallay shows the current user location right. In my case i am showing another location on map ,such that the map loads the current location and zoomed to the location i have given .. but, the current location point was not showing (the blue one which comes automaticay..).
i have given mapView.showCurrentLocation=TRUE; but its not showing .
so could any one tells the way it works and it should say the current location mark and then zoomed to the point i have given.
Thanks
Is there any way to find out which UITableViewCell is at the top of the scroll window?
I'd like to get the current scroll position so that I can save it when the app exits. When the app gets started I want to scroll to the position it was at when it last exited.
Hi
is there a method / possibility to run a function when the scrollview is scrolling?
i found scroll start and scroll end solutions but nothing like a onIsScrolling ...
is there a built in solution? or whats the best workaround (nstimer)?
thanks
Alex
Hi all,
I'm trying to make an appwidget where I have a dialog pop up on top of the home screen. (Ex the Facebook widget). I have button on the widget and an activity that I run when the button is clicked. I have the activity set to the Theme.Translucent.NoTitleBar theme so that the dialog and/or toast I have should pop up over the home screen.
Anyways, whenever I have the transparent activity open, it opens the application instead of staying on the home screen.
Any help would be appreciated! Thanks in advance!
I have some NSString varibales that incude items like
Ð and Õ and if I do
cell.textLabel.text = person.name;
and if it contains one of those characters the cell.textlabel is blank!
I have discovered that if I use
NSString *col1 = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
To pull my data back it pulls back null, however using the deprectared method
NSString *col1 = [NSString stringWithCString:(char *)sqlite3_column_text(compiledStatement, 0)];
Shows the characters!
Any ideas?
I am trying to do something similar to this stackoverflow posting. What I want to do is to read the definition of an activity or service from the SD card. To avoid manifest permission issues, I create a shell version of this activity in the .apk, but try to replace it with an activity of the same name residing on the SD card at run time. Unfortunately, I am able to load the activity class definition from the SD card using DexClassLoader, but the original class definition is the one that is executed. Is there a way to specify that the new class definition replaces the old one, or any suggestions on avoiding the manifest permission issues without actually providing the needed activity in the package? The code sample:
ClassLoader cl = new DexClassLoader("/sdcard/mypath/My.apk",
getFilesDir().getAbsolutePath(),
null,
MainActivity.class.getClassLoader());
try {
Class<?> c = cl.loadClass("com.android.my.path.to.a.loaded.activity");
Intent i = new Intent(getBaseContext(), c);
startActivity(i);
}
catch (Exception e) {
Intead of launching the com.android.my.path.to.a.loaded.activity specified in /sdcard/mypath/My.apk, it launches the activity statically loaded into the project.
I'm fairly new to iPhone programming and am trying to implement a double-component PickerView. At this point the picker works fine in terms of taking user input, created with Interface Builder. However, I need to change the font size to accommodate the text length in each column. I very much would appreciate any link to a straightforward method to creating a multi-component picker with an adjustable font size. Seems like it is not possible if Interface Builder is used to create the picker. So far I have not found any code links that address this issue in detail.
Thanks in advance.
After going into Edit mode, moving a cell, and leaving edit mode, i am left with one extra cell sitting on top of its duplicate cell while still in edit mode.
The problem has to be somewhere in here:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
NSMutableArray *array = [[fetchedResultsController fetchedObjects] mutableCopy];
id objectToMove = [[array objectAtIndex:sourceIndexPath.row] retain];
[array removeObjectAtIndex:sourceIndexPath.row];
[array insertObject:objectToMove atIndex:destinationIndexPath.row];
[objectToMove release];
for (int i=0; i<[array count]; i++) {
[(NSManagedObject *)[array objectAtIndex:i] setValue:[NSNumber numberWithInt:i] forKey:@"userOrder"];
}
[array release];
}
Any guidance greatly appreciated!
Hey
is there any way to send whats in a text view (im trying to make a suggestion box) to my email address?
example
user types in the box " I think you should add twitter support"
then that is sent in the background to my email address [email protected]
then a message is popped up on the screen saying "suggestion sent"
just an example of what i mean
Any ideas, tutorial links would be greatly appreciated guys
Thanks
My application is working fine on the normal iPad display, but I also need to output to VGA out. When I do this, I need to add the view to the external screen's window which seems to mean that I can't use it to accept input from the iPad screen.
I want to redirect input from the iPad's window to the window displaying on the external screen. As far as I can tell there's no standard method of doing this.
I've tried overriding hitTest on the iPad's window view to send it to the window on the external display, but the coordinates seem to get messed up in the process which makes it nigh unusable.
I've also tried subclassing the iPad's UIWindow and catching events in sendEvent, then trying to send them to the external window, but this doesn't seem to work at all.
Any help would be appreciated, I'm happy to post any code you would like to see.
Thanks,
Jon
Hey Guys,
does anybody know how i can access a custom cell within the - (void)tableView:commitEditingStyle:forRowAtIndexPath:. I need access to my Custom Cell Class to retrieve some parameters.
Thanks.