Store images/files in database

Hoever the practice is to store them normally and save the access route (Uri), sometimes it can be handy to store files/images completely in database.
In sqlite database there are only a few data types, so its easy to choose: files can be stored in a text as a ByteArray.

Lets see a sample code, where we download an image from the Internet then store it in the local database:

  1. //where we want to download it from
  2. URL url = new URL(IMAGE_URL);  //http://example.com/image.jpg
  3. //open the connection
  4. URLConnection ucon = url.openConnection();
  5. //buffer the download
  6. InputStream is = ucon.getInputStream();
  7. ByteArrayBuffer baf = new ByteArrayBuffer(128);
  8. //get the bytes one by one
  9. int current = 0;
  10. while ((current = bis.read()) != -1) {
  11.         baf.append((byte) current);
  12. }
  13.  
  14. //store the data as a ByteArray
  15. //db is a SQLiteDatabase object
  16. ContentValues dataToInsert = new ContentValues();                          

read more

Using an Android phone’s sensors

Accessing the sensor data of a phone, is not too complicated, but since API level 3, a lot of things got deprecated. Using only the emulator, you have only a few (here is one) options, to simulate sensor data. I would recommend the use of a physical phone. Keep in mind, that not all phones have the same sensors integrated! Cheaper phones might not have a temperature sensor, or a gyroscope, but I’m pretty sure, that all Android phones have at least an accelerometer, and an orientation sensor.

Here is an example, how to access acceleration and orientation sensor data (in API level 3 and above), without using any deprecated methods.

read more

Sony to announce Android based TV – State of the Android nation

The news is hot. According to Bloomberg Sony will announce an Android based television in May.

I assume that this action will open up another front for Android Application Development.

The Android platform looks pretty bright from development point of view. Within a short time the one phone (G1) OS has grown into a significant player in the operating system market.
Statistics clearly show that Android is heavily gaining market share in the smartphone market. That is already a stable trend beyond discussion.

read more

Facebook Developer News May 19, 2010

We’re excited to announce some new features we’ve released recently: the ability to get your stream stories translated and programmatically control migrations and block users on Facebook Pages.

Getting Your Stream Stories Translated

We’ve heard many requests for this and are happy to announce that you can now include fb:intl tags in the stories you post with stream.publish. Now your users can translate your stream stories for a more universal experience. Read the Internationalization Guide for more information.

Enabling New Platform Features

We launched two Migrations API methods so you can programmatically control whether you want to enable or disable new Platform features during their migration stage. Call migrations.getStatuses to return the list of migrations available, then use migrations.setStatus to set the migration.

Blocking Users on a Facebook Page

If you administer a Facebook Page, you can now use pages.blockFan to prevent the specified user from posting to the Page’s Wall.

Staying Informed

Keep an eye on this blog to get the latest developer news, and check Platform Live Status to see the current state of Facebook Platform. You can subscribe to them both via email. We also publish a weekly article that lists the week’s code check-ins impacting developers.

We hope you familiarize yourself with these features and we welcome your feedback in the Developer Forum.

A Pete, un escritor de Facebook, le gustan las noticias traducidas.

After f8: Personalized Social Plugins Now on 100,000+ Sites

Facebook Platform’s tools enable you to capture the power of the social graph. On Facebook, we’ve seen how much more people engage with different content — such as photos, events, and games — when their friends are involved. Now, our social plugins offer you a toolkit of social functionality that you can add to your website. These personalized experiences catch the attention of your users because, without any setup or data shared, they can immediately see what their friends find most interesting and engaging on your site.

We launched Facebook Connect in late 2008 as the original initiative to help websites and other applications integrate Facebook Platform. In a little over one year, more than 250,000 sites are using our APIs to provide social context in their products. We think there are tremendous opportunities for deep integration with our APIs but, after exploring many common use cases, social plugins emerged as a lightweight way for both developers and users to benefit. Now just one line of HTML turns on the ability for users to engage with content through the Like button, and see their friends’ actions through the Activity Feed and Recommendations plugins.

More than 100,000 sites have already integrated social plugins. Across various industries, people have shown that they want to interact and share and see what their friends recommend. We are excited to report some early results that website developers have shared with us:

  • News: News sites have implemented social plugins to help surface individualized content for readers, and in the process seen significant increases in daily referral traffic from Facebook. For instance, Facebook referral traffic increased by 250% for ABC News and 80% for The Globe and Mail, Canada’s largest-circulation national newspaper. The Globe and Mail has also found that people who have liked their Facebook Page are more engaged on their site — and comment, share, and read more.
  • Movies & Video: IMDb.com has seen daily referral traffic from Facebook double, and its users have generated more than 350,000 likes. Dailymotion, one of the top 50 most-trafficked websites in the world, has seen users click the Like button tens of thousands of times per day on their site. As an example, more than 250,000 users have engaged with one of the most popular videos on Dailymotion, PIXELS by Patrick Jean, and a quarter of its views are from Facebook users.
  • Sports: NHL.com, the official website of the National Hockey League, has seen an 80% increase in referral traffic from Facebook, as people interact with articles, scores and videos.
  • Publishing: Scribd, a site that helps authors publish their writing, has seen their referral traffic from Facebook double as authors gain followers among groups of Facebook friends.

We think the story behind these stats is more important than the stats themselves. As we’ve found on Facebook, people share, read, and generally engage more with any type of content when it’s surfaced through friends and people they know and trust. The results above support this. We’re bringing activities that have been social in the offline world, such as sharing news, reviews, and sports enthusiasm, and giving sites a way for their users to experience their content with friends.

Beyond Social Plugins

In addition to these early successes with social plugins, many sites continue to implement Facebook into their login and core product experience. SimplyHired, a job search engine and recruitment advertising network, has found that users who log in with Facebook are twice as engaged as non-Facebook users. When people use their Facebook accounts to connect with SimplyHired, they see job openings available at companies where their friends work and at companies whose Facebook Pages they’ve liked.

Personera, a site helping people create personalized print materials, has also integrated with Facebook to enable users to create calendars with their Facebook photos and events, and even populate them with their friends’ birthdays. They’ve found that Facebook users generate 50% more pageviews, spend 25% more time on site, and have a 20% lower bounce rate.

We’re excited to see social plugins and our other APIs create great user experiences for users and developers. Learn more about other implementations in our showcase, and share your new implementations and how they’ve worked for you on the Facebook Platform Page.

Justin, who works on the Facebook Developer Network team, likes the New Orleans Saints on ESPN.com.

After f8: Implementing the Open Graph Protocol around the Web

We shared an update last week about the products launched at f8 and that over 50,000 websites have already implemented the new social plugins to become more personalized. We created the Open Graph protocol in support of social plugins as part of our efforts to help realize the vision of the Open Graph.

Any website can implement the Open Graph protocol. It allows any web page to become a rich object in any social graph, making it easy to find what people are liking across the Web — from a movie to a blog. To start integrating the Open Graph protocol into your Web pages, read our documentation.

Last week, Facebook’s David Recordon gave a presentation at the WWW Conference explaining the design decisions behind the Open Graph protocol, which is embedded below. Additionally, members of the W3C’s Linked Data Camp helped to develop a RDF schema file which relates the Open Graph protocol to existing ontologies (such as Dublin Core, FOAF, and DBpedia).

Open Graph Protocol Design Decisions

Developers have created Open Graph protocol implementations in Java, Perl, PHP, and Ruby, as well as a WordPress plugin that makes it easy to add the metadata to any blog. Services like og:it parse any Web page and display Open Graph protocol data. Toby Inkster hacked together a system that converts the Open Graph protocol RDFa markup to JSON and Chris Thorpe created OpenGraph.in, which outputs HTML and JSON.

Beyond helping relate the Open Graph protocol to Semantic Web technologies and developing a variety of open source implementations, the community identified that a page type for an ‘article’ (such as a blog post or story on CNN) was missing. Multiple developers stood up saying that they would implement this new type if it were to exist, and it’s now part of the specification.(We’ll be shipping support for the new article type this week.)

Even though we released the protocol less than two weeks ago, it’s clear that a community is already forming around it. This community is already taking an active part in its evolution and developers are excited about building upon these new tools. We look forward to even more development and adoption in the coming weeks and months. Visit the Open Graph protocol site site for more information.

Mark, a product manager on the Facebook Platform team, likes the Open Graph protocol.

Improving the Platform Experience and Policy Transparency

As stewards of the rapidly growing Facebook Platform, we’re committed to creating an ecosystem that developers find compelling and encourages them to build engaging applications. We believe a strong user experience — that’s both appealing and trustworthy — is an integral part of a compelling platform. Trust keeps users coming back, and encourages them to share with their friends. Both help your applications grow.

However, spam undermines user trust. We often hear this concern from developers and users alike. We define spam as something the recipient sees as inauthentic, promotional, irrelevant, clearly uninitiated by the sender, or simply voluminous. We want users to have confidence that the information delivered to them on Facebook is relevant and useful.

We’re taking steps to help reduce spam on Facebook in two ways:

  • By increasing our presence in the Developer Forum, where we can answer your questions about spam and other policy-related issues
  • By increasing our enforcement against spammy applications

In response to your requests for more guidance and transparency about policy from Facebook, the policy team will increase its activity in the Developer Forum, answering your questions and starting new discussions around topics on our mind. When we find themes and conclusions, we’ll publish them on the Examples and Explanations document, where you can see our intentions around policy.

At the same time, to provide a better user experience, we’re stepping up our enforcement efforts against spammy applications, especially against spam in stream stories. It’s important that all developers adhere to our guidelines, from the smallest to the largest. Unfortunately, this has not always been the case. It’s our intention to change this through enhanced enforcement efforts.

We are also performing more automated actions on Platform, where we remove spammy applications based on user feedback, machine learning, and various algorithms. We think you’ll agree that removing spammy applications adds to user trust of Platform, and in turn will make the ecosystem stronger for all developers.

These steps are part of our continued focus on providing the best user experience. We recently updated our policies as part of publishing the Facebook developer roadmap, talked about how we would enforce based on principles, and updated you on our stream publishing policies. We’re very pleased with how the user experience across Platform has improved so far, and we’ll continue to make improvements as needed.

We invite you to submit policy questions in the Developer Forum and look forward to working with you to create an even better user experience on Facebook Platform.

Robyn is looking forward to improved experiences on Facebook Platform for users and developers.

After f8 – Resources for Building the Personalized Web

Thanks to all of you who made f8 such a great event — from the more than 1,500 attendees to the 120,000 people who joined us on f8 Live, our live stream channel. Below is a summary of our new tools, how to start using them, and links to resources from f8.

Guide to New Developer Tools

At f8, we announced several new tools and features for developing with Facebook Platform. We’ve created an upgrade guide to give you more details on new products, specifically:

All the existing APIs, original JavaScript client, and authentication system will continue to work. Read our upgrade guide for more details, especially if you have existing applications or websites which are integrated with Facebook.

Facebook Connect

As you may have seen, we’re transitioning away from the Facebook Connect brand to reflect that there is one underlying platform behind any integration with Facebook, whether you are building an application on Facebook.com, a website, or on a device. This change has no impact for the 250,000 sites using Facebook Connect today. All the same technologies exist on Facebook Platform, so no transition is needed. An option you may want to consider, though, is using either the “Login with Facebook” button or our new button with faces, which have seen higher conversion rates.

More on Social Plugins and the Open Graph

At f8, we also launched new tools called social plugins — including the Like button, Activity Feed, and Recommendations — on more than 75 websites. Already, just one week since launch, more than 50,000 sites across the Web have implemented the new plugins. We are thrilled by the strong adoption so far as developers realize how easy social plugins are to use and how powerful they are in engaging users in a frictionless experience without requiring them to share any personal information.

To support these plugins, we launched the Open Graph protocol, with which you can add metadata to any Web page so that it can be represented within any social graph.

Just as we provide each person on Facebook with a unique experience via News Feed, you can now do the same with your site through these basic tools. We can’t wait to see what you build.

Wrapping up f8 2010

Those at f8 were the first non-Facebook employees to experience Presence, an internal Hackathon project that functioned as a system at f8 where attendees could swipe their badges and easily share their activities and even get their photos taken, tagged, and shared. More than 1,200 people interacted with Presence at f8, 1,400 photos were taken at photo booths, and people published more than 2,600 stories to their News Feeds.

While f8 was going on in San Francisco, more than 300 members of the European developer community celebrated f8 simultaneously in London. At the Facebook Developer Garage London, attendees connected with Facebook employees and European launch partners to discuss news from f8.

If you missed f8, or want to relive the keynotes and sessions, you can view recorded videos on f8 Live.

Watch live streaming video from the f8 conference at livestream.com

Be sure to visit our new developer site, complete with products, documentation, and tools. You’ll also find a showcase of how sites around the Web are using social plugins.

You can direct your questions to the Developer Forum, and share your new implementations on the Facebook Platform Page.

Sandra, a product marketing manager on the Facebook Developer Network team, is liking things all over the Web.

A New Data Model

Earlier today we introduced the new Graph API to help you more easily access data from Facebook. To improve the Facebook Platform experience for developers and users, this data is now backed by a simpler data policy and a unified data permissions dialog for users. These changes reflect two core beliefs: first, user data belongs to the user; they should have transparency and control over it. And second, you should be able to build relationships with your users; we should not be in the way. We hope these improvements will foster more trust and engagement for our platform and the applications and websites using it.

New Data Permissions Dialog

Giving users transparency and control over the data they share

We’re combining all of our permissions dialogs into one unified dialog. With this change, we’re giving users transparency and control over the information they give applications or websites; developers benefit from a streamlined flow for requesting multiple permissions. When users go to your website or application on Facebook, you can ask them in one step for all the information you need, including access to their stream, friends’ information, or even their email address. By default, users grant you access to their public data. If you need private data or friends’ data, the new dialog will clearly present these requests, so users can understand what you need, make informed choices, and quickly get started.

New Data Policy

Simplifying the developer experience and enabling closer relationships with users

We are removing our 24-hour caching restriction which posed a technical burden on developers. This restriction forced applications with millions of users to ping Facebook’s servers millions of times each day to perform basic functions like displaying a user’s name back to them. Most of you had to write special code paths to handle Facebook data. As part of today’s changes, you can store data — only the data users have granted you access to, of course — and more easily write fast, high-quality applications. With the new real-time updates feature, you can also be immediately notified when your users’ information changes, including their profile information, friends, and Wall posts.

Giving users more control and transparency also permits us to add new policies which let you build a closer relationship with your users. For users who connect with your application or website, you will now have full access to use basic account information, including user ID, name, and email (once a user grants permission) in any way you believe provides a richer experience for your users. In addition, with explicit user consent, you can use their data for purposes beyond displaying it back to the user. However, you’ll now need to have your own privacy policy and enable users to delete all of their data from your app. We’ve also clarified our advertising-related restrictions.

Next Steps

You can opt in to using the new permissions dialog by going to the Migrations tab of the Developer application and enabling “New Data Permissions.” Nothing will change for your existing users; you will retain the same level of data access you had before. For new users who see the new permissions dialog once you enable it, you will have access to all the data you request. On June 1, 2010, we’ll automatically transition all Facebook Platform applications and websites who have not yet migrated.

The new data policies take effect today, April 21, 2010.

Learn More

This new data model makes developing on Facebook Platform easier and more useful, while users gain transparency and control. We believe these changes lay the foundation for the next generation of social and personalized experiences around the Web.

Ethan Beard, director of the Facebook Developer Network team, is excited to meet all of you at f8 today.

The Next Evolution of Facebook Platform

We’re hosting our third f8 conference in San Francisco today. There are two important themes behind everything we’re delivering today. First, the Web is moving to a model based on the connections between people and all the things they care about. Second, this connections-based Web is well on its way to being built and providing value to both users and developers — the underlying graph of connections just needs to be mapped in a way that makes it easy to use and interoperable.

Today we are introducing three new components of Facebook Platform to make the connections-based Web more real: social plugins, the Open Graph protocol, and the Graph API.

Social Plugins


Instantly engaging social experiences with just one line of HTML

Social plugins are the easiest way to integrate the social graph into your site and provide an instantly personalized experience to your users. The most important plugin is the Like button, available with one line of HTML. On Facebook and now anywhere, the Like button offers users a lightweight and consistent way to share the things and topics that interest them. With the Like button in place, you can leverage the other Facebook social plugins to personalize your site and drive traffic and engagement. The Activity Feed plugin shows users what their friends have liked on your site; the Recommendations plugin gives content suggestions from your site. The Facepile plugin shows profile pictures of the user’s friends who have already signed up for your site. As with the Like button, these social plugins are simple to use: via a line of HTML, or XFBML tags if you choose to use our new, faster — and opened-sourced — JavaScript SDK.

Open Graph Protocol

Any webpage can now easily become part of the social graph

On Facebook, users build their profiles through connections to what they care about — be it their friends or their favorite sports teams, bottles of wine, or celebrities. The Open Graph protocol opens up the social graph and lets your pages become objects that users can add to their profiles. When a user establishes this connection by clicking Like on one of your Open Graph-enabled pages, you gain the lasting capabilities of Facebook Pages: a link from the user’s profile, ability to publish to the user’s News Feed, inclusion in search on Facebook, and analytics through our revamped Insights product.

In summary, by giving your users better, simpler ways to connect with the content on your site, you can then use those connections to provide more personalized, relevant experiences. And the product only gets better over time. The more people that come back to your site, the more connections that are made, the better your service becomes.

Graph API

A drastically simplified way for developers to use Facebook Platform

We are excited to introduce the Graph API, a redesign of our core API that reflects the structure of the graph. This new API is a simple, consistent representation of data in the graph, so that all objects and APIs can be accessed via URLs.

We’ve also made it much easier to integrate with Facebook by using a simplified, standards-based method for authentication and authorization.We’ve adopted OAuth 2.0, a standard we’ve co-authored with the open community, including representatives from Google, Twitter, Yahoo, and others.

The Graph API is not only simpler, it is more powerful. We’ve enabled a search feature which lets you search over objects like people and events, and over the stream — both public stream updates and personalized ones for your users. In addition, the graph is ever-changing, so we’re launching real-time updates to let you subscribe to updates to user data. We’ll continue to support our old REST API, but will focus future improvements on the Graph API.

Hacking the Graph

People make meaningful connections everywhere, on every site they visit, on every device they use. As we open the graph, developers can use these connections to create a smarter, more personalized Web that gets better with every action taken.

We’re excited that more than 75 sites are launching today with social plugins, many with Open Graph-enabled pages. In the first 24 hours, these sites will serve over 1 billion Like buttons. We’ve also announced special partnerships with Microsoft, Pandora, and Yelp to build experiences where people can seamlessly transition between Facebook and other services. These unique partnerships help users discover how bringing friends along makes their Web experience better.

Through Facebook’s new tools and technologies, every developer — new and existing, big and small, novice and advanced — can engage users, build businesses, and revolutionize industries. This year’s f8 is about hacking the graph; we hope you’ll join us.

Learn more about these launches on our new developer site at developers.facebook.com.

Bret Taylor, head of Facebook Platform products, is stoked that f8 is today.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes