
android in practice
主的器皿
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
android in practice_Using the AlarmManager(portfolio project)
system-level alarms.you can’t guarantee that it’ll still be running at that point in the future.To ensure that our code is executed at the desired time, we can’t rely on the Service because the OS原创 2012-12-26 14:51:43 · 616 阅读 · 0 评论 -
android in practice_Working with a custom ContentProvider(MyMoviesContentProvider)
The ContentProvider API is a thin layer on top of a SQLite database.This example showcased using the ContactsContract provider. The android.provider package also contains providers for the calendar原创 2013-01-17 16:20:36 · 634 阅读 · 0 评论 -
android in practice_Using Intents(GoodShares project)
You need to send a request with data to another application, or you need to send a response to a request from another application. The application making the requestwill cede control to another appl原创 2013-01-09 16:41:15 · 520 阅读 · 0 评论 -
android in practice_SQLiteManager
it’s crossplatform(it’s a Firefox browser extension), open source, and free.原创 2013-01-05 16:10:08 · 474 阅读 · 0 评论 -
android in practice_Using internal storage(FileExplorer project)
The first Activity in FileExplorer is a screen that allows users to choose whether to work with the internal or external storage.If the user chooses the internal storage path, we then go to an Act原创 2013-01-04 13:31:55 · 838 阅读 · 0 评论 -
android in practice_Displaying splash screens with timers(MyMovies project)
You want to execute a delayed task that executes its logic only after a certain amount of time has passed.The splash image can be dropped in the res/drawables folder:splash.pngThe layout for a原创 2013-01-02 15:29:57 · 603 阅读 · 0 评论 -
android in practice_Preparing for configuration changes(MyMovies project)
Any configuration change will terminate the currently visible Activity and restart it using the new system configuration, so always be prepared for interruptions.You need to perform tasks asyn原创 2013-01-01 18:52:23 · 535 阅读 · 0 评论 -
android in practice_Using Cloud to Device Messaging(portfolio project)
It’s important to think about the effect that the preceding code will have on battery life. The CPU is going to be woken up to make a network call, update a local database,and possibly create Notifi原创 2012-12-27 16:18:31 · 615 阅读 · 0 评论 -
android in practice_Using a Service for caching data(portfolio project)
Caching of data can make a huge difference in the performance of any application.You want to centralize the access to this data in one place and cache it, since retrieving it over the network is slo原创 2012-12-25 15:51:21 · 510 阅读 · 0 评论 -
android in practice_Keeping Services awake(portfolio project)
AlarmManager help us to resurrect our killed Service. But that resurrection could be short-lived.the Service needs to do—retrieve fresh stock data from the Internet and send out Notifications if neede原创 2012-12-27 14:38:09 · 775 阅读 · 0 评论 -
android in practice_Implementing jobs with AsyncTask(MyMovies project)
AsyncTask offers an easy-to-use (but more limited).You need to perform an asynchronous job that follows a pre-process/process/postprocess pattern, and are looking for a code template that allows y原创 2013-01-01 18:18:34 · 592 阅读 · 0 评论 -
android in practice_Using external storage(FileExplorer project)
You want to store data on the external storage. Also, you want to be able to easily determine when the external storage is and isn’t available.create layout file external_storage.xml<LinearLa原创 2013-01-04 15:55:18 · 1109 阅读 · 0 评论 -
Retrying requests using request-retry handlers
Realizing that HTTP requests can fail when the user is on the move, you want to put a proper request-retry system in place so that when a request fails because of a flaky network,you can silently rese原创 2013-01-31 15:13:08 · 4651 阅读 · 0 评论 -
Parsing XML with XmlPull_(MyMoviesWithHttpClient)
explicitly move forward through an XML document bit by bit, and skip any entity you encounter in which you’re not interested. That’s what a pull parser does.You’re looking for a lightweight way to p原创 2013-01-31 13:56:15 · 471 阅读 · 0 评论 -
HTTP with Apache HttpClient_(MyMoviesWithHttpClient)
The Apache HTTP Components are composed of two parts: HttpCore, a set of lowlevel classes for handling HTTP connections, and HttpClient, a more high-level set ofclasses built on top of HttpCore, whi原创 2013-01-30 10:39:49 · 703 阅读 · 0 评论 -
HTTP with HttpURLConnection_(MyMoviesWithUpdateNotice)
You need to perform simple networking tasks via HTTP, such as downloading a file, and you want to avoid the performance penalty imposed by the more high-level, much larger and more complex Apache Http原创 2013-01-29 17:30:32 · 722 阅读 · 0 评论 -
android in practice_Process-to-process sharing
we must send data across process boundaries. The first and most common way of doing this is by using Intents.原创 2013-01-09 16:15:59 · 423 阅读 · 0 评论 -
android in practice_Creating a data manager(MyMoviesDataBases project)
Because our DAOs are each unaware of any table other than their own, we’re also going to create a DataManager interface, an implementation class that will wrap themultiple DAOs and take care of the原创 2013-01-05 16:00:36 · 727 阅读 · 0 评论 -
android in practice_Maintaining preferences(MyMoviesdatabase project)
You want an easy way to store simple information, such as strings and primitive values.You can use SharedPreferences to easily store and retrieve data.SharedPreferences prefs = getSharedPreference原创 2013-01-04 17:37:10 · 494 阅读 · 0 评论 -
android in practice_Making sure files are saved with sync
You need to guarantee that file data is written to disk immediately, regardless of the filesystem in use and the platform version.Syncing ensures that the buffer catches up with the physical disk.You原创 2013-01-04 16:32:39 · 436 阅读 · 0 评论 -
Using a LocationListener
How do you determine whether a certain provider is enabled? And if not enabled, how do you prompt the user to enable that provider because your application may require it?A LocationListener is simpl原创 2013-02-06 13:58:16 · 962 阅读 · 0 评论 -
Location managers, providers, and listeners
The LocationManager class is the gateway into all the location related services on Android. It’s a system service that allows you to access location providers, set up locationupdate listeners and pr原创 2013-02-01 11:38:41 · 730 阅读 · 0 评论 -
android in practice_Implementing custom message loops(ProducerConsumer project)
You’re writing an application in which several threads must exchange messages, as in a producer-consumer scenario.We’ve already seen how to bind a handler and use it to send messages. The interestin原创 2013-01-04 10:49:58 · 485 阅读 · 0 评论 -
android in practice_Managing threads in thread pools(MyMovies project)
every list item is created in the list adapter’s getView method, and this method is called whenever you scroll the list to see more items. We could use this method to spawn a thread that downloads the原创 2012-12-31 15:28:37 · 707 阅读 · 0 评论 -
Parsing JSON_(MyMoviesWithHttpClient)
The Ajax (Asynchronous JavaScript and XML).You either want to integrate with a web service that only supports JSON, or you want to take advantage of JSON’s benefits such as being able to efficiently原创 2013-01-31 14:45:40 · 517 阅读 · 0 评论 -
Parsing XML with SAX_(MyMoviesWithHttpClient)
Android bundles three different kinds of parser APIs(DOM, SAX, and XmlPull).whether they need to load the entire XML document into memory up front. Parsers based on the Document Object Model (DOM) d原创 2013-01-30 15:42:54 · 714 阅读 · 0 评论 -
Consuming XML and JSON web services (MyMoviesWithHttpClient)
A web service is a set of server-side interfaces exposed on the Internet using web technologies such as HTTP for data transfer or XML and JSON for data serialization. Unlike web sites, web services ar原创 2013-01-30 14:00:56 · 1291 阅读 · 0 评论 -
android in practice_create and start a service(portfolio project)
Main Application, Main Process, Main Service,Main Task,Main Activity vs Multiply Applications,Multiply Processes,Multiply Services,Multiply Tasks, Multiply ActivitiesThe way to fully implement multi原创 2012-12-14 14:52:35 · 465 阅读 · 0 评论 -
android in practice_Managing a stateful list/Header and footer views
(1)ViewHolder pattern, which will make your list render significantly faster and hence scroll more smoothly.(2) Adapter, the views for our ListView are bound to the data source we’ll use a static原创 2012-12-04 11:47:27 · 825 阅读 · 0 评论 -
android in practice_framework
原创 2012-12-04 09:20:19 · 416 阅读 · 0 评论 -
android in practice_create model、table class and sqlitehelper(MyMoviesDataBases project)
In essence, cursors iterate over result sets and provide access to data one row at a time.first,We’ll want simple model objects,second,we need create table class with static methods and OpenSql原创 2013-01-05 12:42:52 · 1110 阅读 · 0 评论 -
android in practice_Share data by sharing Context
You have two or more applications that are closely related and depend on each other. You want them to share private resources such as files or code that must not be visibleto other applications, but原创 2013-01-17 10:11:46 · 647 阅读 · 0 评论 -
Handling network configuration changes
In any event, you must somehow get hold of these settings, and be notified when, for example, the proxy server changes while your application is running, so that you can update HttpClient to send requ原创 2013-01-31 15:51:07 · 623 阅读 · 0 评论 -
Configuring a thread-safe HttpClient(MyMoviesWithHttpClient)
If you plan to develop applications that only target Android 2.2 or newer, you may consider skipping this technique.You’re running threads that need to communicate with a web server through a single原创 2013-01-30 11:29:00 · 858 阅读 · 0 评论 -
android in practice_Using standard ContentProviders(AutoForm)
AndroidManifest.xml<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="example.autoform" android:versionCode="1" android:versionName="1.0" > <uses-sdk原创 2013-01-17 14:26:53 · 1888 阅读 · 0 评论 -
android in practice_Making remote procedure calls(GoodShares project)
You need to pass data to another app so that it can perform some operation on that data and return a result back to your app. You don’t want to give up control flow to this other application; you want原创 2013-01-11 17:04:04 · 744 阅读 · 0 评论 -
android in practice_Communicating change between threads(ImageDownloadWithMessagePassing)
by design it’s impossible to update user interface elements from outside the main UI thread.if you’re sharing state between two or more threads you always need to synchronize this shared data usin原创 2012-12-29 03:20:18 · 655 阅读 · 0 评论 -
android in practice_Basic threading(simpleImageDownload project)
After clicking the button that initiates the download, Android will give your application no more than a few seconds to respond to that input event. Otherwise, it’ll kill it and raise the previously m原创 2012-12-28 22:42:59 · 499 阅读 · 0 评论 -
android in practice_Threads and concurrency
you can run services in separate processes, but that isn’t a requirement. In fact, unless you specify a process ID explicitly, they won’t.one golden rule about user interfaces is to always remain re原创 2012-12-28 11:29:19 · 595 阅读 · 0 评论 -
android in practice_Creating notifications(portfolio project)
Having the caching data in the background Service allows that Service to do other things with that data. A common example of this is to create notifications based on the data that’s retrieved from the原创 2012-12-26 13:27:30 · 672 阅读 · 0 评论