An Android Developer's Approach to Handling SQLite Hangups
by Jesse Hendrickson, Lead Android Engineer
So, here’s the situation. I was stress testing user authentication by repeatedly logging in and out of our Android application. Most of the time, this works great. Logging out would successfully clear all locally stored user data, drop the backing SQLite database, and return the user the Login screen. Every so often, however, logging out would cause the application to hang indefinitely. (This is, obviously, a bad thing).
Digging a bit deeper, I found that calling close() on my SQLiteOpenHelper singleton was causing the hangup. Even though Android’s SQLiteDatabase uses an internal locking mechanism to accommodate access by multiple Threads, deadlock occurred when I tried to close the database with many Threads writing to it. This explains why the hangups would not consistently occur: they only happened while simultaneously logging out in one Thread, and locally persisting server data in another.
As a result, it was impossible to close() the database, and subsequently impossible to move ahead in the logout process. Not good.
Knowing that I didn’t want to to close the SQLiteDatabase while other Threads were writing to it, I reached into the depths of computer science knowledge and decided to do the following:
Sleep.
Well, I myself didn’t sleep, regrettably. I sleep()’d the Thread that calls close() until the other Threads finished their writes and the database lock became available. I added this simple method to my SQLiteOpenHelper subclass:
public void closeSafely() { try { SQLiteDatabase db = getWritableDatabase(); while (db.isDbLockedByOtherThreads()) { Thread.sleep(50); } close(); } catch (InterruptedException e) { } }
SQLiteDatabase.isDbLockedByOtherThreads() does exactly what is sounds like: it checks to see if the database lock is held by another Thread.
Adding these few lines of code solved the deadlock issue. To avoid sleeping for too long, I added some logic that prevented other Threads from writing to the database when the user is logging out, so the closeSafely() method will only sleep at most for a couple hundred milliseconds.
Simple solutions like the one above often work surprisingly well. Avoid convincing yourself that a problem as complicated Thread and SQLite synchronization needs to have just as complicated a solution!
Your Phone's Calendar Sucks (and What You Should Do About It)
by Jacob Smith, Director of Business Development
Let's face it; phone calendars aren't much fun. They're a lot of work to maintain, and very limited when it comes to plan-sharing and event discovery. Calendar sharing is cumbersome, and meeting invites are awkwardly formal between friends and loved ones.
As a result, finding out what’s coming up leaves most of us in a never-ending hunt for information. If you’re like most people, you spend a huge amount of time fishing for upcoming events: When is the next game? When does my favorite TV show premier? What concerts are coming up? When does my girlfriend have book club? You may check dozens of websites and read through piles of emails, or incessantly text your friends and family members just to find out what’s happening and when.
There's got to be a better way! What if your calendar just knew which upcoming events mattered to you most?
The Evolution of the Calendar
If you’re anything like me, you’re 100% hooked to your calendar. My calendar is a direct extension of my brain, and without it, I’d just be stumbling around aimlessly all day. Quite frankly, it's difficult to imagine a time before this essential tool.
Calendars have come a long way in a relatively short period on time. For a majority of the last century, paper calendars were the way to go. The on-the-go businessmen and women of the day would carry pocket-sized planners to keep track of their busy schedules. By the mid-90’s, computers had burst onto the scene, and slowly but surely digital calendars entered into the mix. Then came PDA’s and cell phones, merging the digital calendar experience with the frenzied, drive-thru-Starbucks needs of today’s businessperson.
Despite this revolutionary change in medium, the calendar itself has not changed much from a functionality standpoint.
Funky Functionality
Phone calendars are extremely limited. What you've essentially got is a pocketbook that lets you set reminders and send meeting invites. If you want to go beyond your day-to-day meetings and appointments, you're left scouring the Internet for information about what's upcoming.
Not to mention the social aspects of the calendar are a mess. Want to see what each of your friends are doing this weekend? Your options are as follows:
Share calendars- Google Calendar and other major calendars offer "binary" or all-or-nothing 1-to-1 sharing. You can see NONE of your friend's events or you see ALL of them. But who really wants to share their entire calendar with all of their friends?
Meeting invites - Unless you are inviting co-workers to a team meeting, this is the most awkward possible way to make plans.
Text, call, or email - Time consuming, and potentially annoying.
None of these options really cut it, and consequently, life is full of missed opportunities. The concert we would have gone to. The season premier we would have watched. The party we wished we’d known about. It's 2013, and that's the best we can do??
The Calendar Revolution
UpTo is reinventing the mobile calendar as we know it. Your life is about so much more than just meetings and appointments, and your calendar should reflect that. You deserve a comprehensive, personalized view of what's upcoming.
The current system is broken. UpTo is here to fix it, and we’re just getting started. UpTo 2.0 is coming soon, and it will change the way you think about the word “calendar.” It's time to get up, ditch your archaic sundial of a calendar, and join the revolution!
Calling All Businesses or Organizations: Publish Your Calendar As a Stream on UpTo
Here at UpTo HQ, we are very good listeners. You told us what you wanted, and we heard you loud and clear. Today we are proud to announce that any business or organization in the world can now publish their calendar as a public stream on UpTo, for free!
A big part of the UpTo experience is the thousands of public event streams we have created with you in mind. Every team you’re a fan of, every yoga class you attend, every school and organization you’re a part of. They all deserve a spot in one unified calendar.
We’ve got the big guys covered (sports, TV, music, movies, concert venues, etc.), but it’s the local shops with unique schedules that are the most important, and that’s where our new stream portal (aka the "Stream Engine") comes into play.
For the first time, we’re giving our users the power to create public event streams. From local fitness studios, dive bars, and pre-schools, to niche interests like comics, Lady Gaga, and tattoo expos it’s yours for the making!
How to Create a Stream:
Creating a stream in UpTo is very easy. First go to http://upto.com/streams and log in to the stream portal tool. From there, you can add new streams. Once you create a stream, it automatically becomes searchable in the UpTo mobile app. You can also share your stream via Facebook, Twitter, or email.
It’s the start of a new year and we’ve got a new iPhone release hot off the press for you. If you haven’t updated yet, you can download it here.
We’ve added two new types of push notifications to help you stay in the loop. Head to the settings screen in the app to toggle on notifications for Friends’ Events and Public Stream Events. We give you a little push anytime your friends or event streams you follow share an event. That way you always know what’s coming up.
Event Streams and our Discover section are half the fun. We want you to be able to share your favorites with your favorites. So select a stream you think your friends and family would love, tap the share button in the top right corner and share any stream via email, message, Twitter or Facebook. Don’t keep these awesome streams to yourself -- sharing is caring.
We think you’re stunningly good looking, and we wanted your individual profile to reflect your amazing looks. Now you can edit your cover photo to your heart’s desire. Whether it’s a photo from your tropical vacation to make us jealous, an adorable shot of your munchkins smearing chocolate all over the place or breathtaking shot skyline shot your options are endless.
Your feedback is the most important and valuable thing to us. So please, share your comments, questions, feature and stream requests. Contact us anytime at support@upto.com. We’re always here to help.
Hey there sports fans! You're a fan of just about every major sport and you have a lot of teams to keep track of. It's a lot to keep straight. The college basketball season is in full swing and if you're lucky, your NFL team of choice is in the playoffs.
At UpTo, we know the importance of every free throw, punt and goal—we never want you to miss a game.
We have streams for every NFL, NBA, and NHL (here's to hoping!) team, as well as the biggest NCAA basketball teams.
All you need to do is head to the Discover screen in UpTo, search by league, city, school or mascot and follow your teams of choice.
Just by following a team, every single game is added to your UpTo feed of events. You can see all your teams' schedules right in line with your own, and choose games to add straight to your calendar simply by tapping the plus to join in.
Interact with your fellow sports fans, predict scores and defend your teams honor by posting comments on any event.
Can't find your favorite team? Send an email to support@upto.com with a stream suggestion and we will hop to it!
At UpTo, it’s our goal to make sure you know about the most important things that are coming up, from Grandma’s 90th Birthday Party to your wedding anniversary (forgetting either of those is a really horrible idea -- we promise). But, not all events are personal things found on a calendar -- and that’s where our discover screen comes in!
We have hand created over 600 event streams with you in mind. From college and professional sports, movie and TV premieres, to national holidays, and local concerts we have covered a lot of bases.
Follow the streams that are most important to you and add events directly to your calendar for your friends to see.
Currently, the power of streams is in our hands, but soon the power will be yours too! Here at UpTo HQ, we are hard at work building an online platform just for you. You’ll have the ability to add event streams of your very own.
In the meantime, It’s important to us that we include everything that matters to you. Simply send an email to support@upto.com and suggest a stream! We will do our best to get your dream stream made just for you!
Born and raised in Detroit, UpTo calls The M@dison Building home.
Our desks are surrounded by other tech startups. Our building is surrounded by some of the coolest sights in Downtown Detroit -- Grand Circus Park, the Detroit Opera House, the Fox, Fillmore Theaters and most importantly Comerica Park, home of the Tigers.
We spend our summers with the windows cracked to hear the roar of the fans long before that mandatory 8 second live TV delay elapses.
Summer is over but Tigers baseball isn’t. The Tigers swept the Yankees to clinch the American League Championship Series (Detrois Vu, much?) and we couldn’t be more excited to be here.
The office is abuzz with Tigers talk and spirit. Here’s to hoping the Tigers bring home a World Series title this year! We’re watching from the roof!
For the four of us, it started with a simple question… Why is it that we can see our friends’ histories on Facebook, and a real-time view of the world’s chatter on Twitter, but we can’t see what the people we care about the most will be up to an hour from now, a day from now or a week from now? Today’s most popular social platforms offer immense social value, but they all have one thing in common - they give users a stream of information that goes backwards in time. Whether it’s a status update on Facebook, a tweet on Twitter or a check-in on Foursquare, by the time we see most of this information being shared, it’s already after-the-fact. When you see that a friend that you’ve wanted to connect with checked-in around the corner three hours ago, what can you do about it? Not a whole lot. But if you see that a friend is going to be around the corner from you tomorrow, it’s a different story. The ‘future-tense’ is actionable.
Our lives are full of upcoming plans. Some are formal and others are spontaneous. Some are a few minutes out and others are a few months out. These plans live on our calendars, in email and in the back (or front) of our mind. But no matter where these plans live, we only get a singular view of what’s coming up in our own life. As a result our lives are full of missed opportunities – every day.
We weren’t the first people to think about the future tense, so we started by looking at what other options already existed. We looked at platforms like Facebook Events and realized that we don’t use these everyday to share what we’re up to because they’re primarily focused on big events that people are broadcasting to large audiences. We needed a platform that not only let users share bigger events, but also enabled the sharing of everyday events. When it comes to everyday events, some may only be relevant to your family, while it makes sense to share others with a broader audience, like your co-workers or your friends. Enabling more frequent sharing required giving users control over exactly what they’re sharing and who they’re sharing with.
We also looked at existing calendars. People who use calendars depend on them. In fact, we found that calendar users check their calendar at least five times a day on average. This is the tool that millions of people worldwide use every day to keep track of their plans. But despite going from paper to the computer to phones, the calendar itself has not evolved – and it’s definitely not social. You can use your calendar to invite someone to an event that they’ll be attending, but you can’t use it to share what you’re up to or to have conversations about upcoming events.
With all of this in mind, our first version of UpTo was focused on sharing calendar events with friends, family and co-workers. Users could connect with friends and bucket them into groups, share events straight from their calendar with different groups, add new events, comment on events – even view a heat map showing which days are busier for different groups. We had built a network layer on top of the native calendar and it didn’t take long for missed opportunities to start turning into opportunities. A colleague’s upcoming call with an investor led to an intro to that investor. A friends dinner plans that were shared on UpTo led to a bigger group getting together for drinks afterwards. The examples went on and on, and most of the content getting shared on UpTo was content that otherwise would not have been shared.
Like other social applications, the value a user got from our first version of UpTo was dependent on that user having friends that were also using our application. But building a network takes time – it rarely happens overnight. For users with friends on UpTo, we noticed that people were primarily sharing events that were already on their calendar. This was good because the calendar is where a lot of our plans live, but we wanted people to share and discover things that may never have been on their calendar. As we started thinking about our first big update, we knew we needed to create more value for ‘User 1’ and encourage the discovery and sharing of a broader set of events.
Our first major update launched last week, and with it we introduced UpTo ‘Event Streams’. With Event Streams, UpTo users can find and follow upcoming event feeds based on their likes and interests with a single tap. And with another tap, users can add an event from these streams to their calendar and share it on UpTo, simultaneously. Now when a user launches UpTo for the first time, they can immediately follow streams ranging from upcoming sporting and tech events to TV premieres and music releases.
We launched Event Streams by partnering with London 2012 Olympic Sponsor - Westfield U.K. UpTo featured a ‘Westfield’ Event Stream highlighting upcoming events happening at Westfield Centres during the Olympics, events happening around London and streams for all Olympic events. But that was just the beginning. With our latest update, we can now add Event Streams for any local business or organization that has upcoming events. If there is an Event Stream that you would like to see in UpTo – whether for a local group or for national events - let us know by e-mailing partners@upto.com.
Our latest release also included a user interface update, Facebook Events integration, a new ‘Add Event’ screen with Foursquare venue look-up for addresses, and the ability to ‘Join’ events. In addition to more iPhone app updates on our roadmap, we also have an Android version of UpTo coming very soon.
We believe that the future-tense presents a massive opportunity and that there are immense benefits to being able to see what’s coming. While other social applications inform users about what recently happened or what’s happening now, UpTo lets you glance into the future. We’re confident that UpTo will open the door for you to new opportunities, better communication and even occasional, planned serendipity. When you check out the future, we think you’ll like what you find.
So download the app (it’s free), follow some Event Streams, share what you’re UpTo with friends and let us know what you think. Good or bad, day or night, we want to hear from you – even if it’s just to say hello. You can email us at founders@upto.com.