Android real-time folder creation method

This article describes the method of creating Android real-time folder. Share with you for your reference. The details are as follows:

Real time folder is a desktop component used to display data information provided by a content provider. To create a real-time folder, you must have two aspects of support. On the one hand, you need to define an activity to create a real-time folder. On the other hand, the ContentProvider of the specified data information URI must support real-time folder query. This section describes how to create real-time folders for applications.

Similar to adding a shortcut on the launcher's desktop, the user can select a real-time folder after long pressing on the desktop, and a list dialog box of available real-time folders will pop up. If we want to add the activity in our application to this list, we only need to add an action as android.intent.action.create when registering the activity_ LIVE_ Intentfilter of folder. In this activity for creating real-time folders, we need to store the information of real-time folders in an intent object in the form of additional information, and return the result to the launcher application for addition. The following table lists the key values and data types of attachment information related to real-time folder information.

Key value and data type of real-time folder

Where display_ There are two modes. When the value is 1, the expanded real-time folder content is displayed in the form of grid, and when the value is 2, it is displayed in the form of list. In addition to the above additional information, the URI of the data to be queried is stored in the intent object in the form of data. Since the ContentProvider of contacts has implemented relevant support for real-time folders, we will take the program to create real-time folders for all contacts as an example in this section.

Testactivity class

Manifest file

Operation results

I hope this article will be helpful to your Android program design.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>