Android-manage the Android mobile desktop

Source: Internet
Author: User

Android-manage the Android mobile desktop

Before getting started with mobile phone programming, I was curious about how theme backgrounds and dynamic wallpapers were made, how to place icons on the mobile phone desktop, and how to manage the Android mobile phone desktop, I have a general understanding of this content, and it is a blind scan.

I believe that users who have used an Android mobile phone can perform operations on the desktop of the mobile phone very clearly. Such as deleting desktop components and adding corresponding components to the desktop.

I learned how to develop Live wallpaper, create shortcuts on the desktop, manage desktop widgets, and develop LiveFolder).

 

The following is an example of a real-time folder that displays the original text.

This real-time folder displays the ContentProvider data, which must be deployed to the simulator before the data returned by ContentProvider can be displayed in the real-time file.

 

Create a project: WordsLiveFolder

Project running effect:

 


 

 

 

 

[Java]
Package org. wwj. desktop;
 
Import android. app. Activity;
Import android. content. Intent;
Import android.net. Uri;
Import android. OS. Bundle;
Import android. provider. LiveFolders;
 
Public class WordsLiveFolder extends Activity {
@ Override
Protected void onCreate (Bundle savedInstanceState ){
// TODO Auto-generated method stub
Super. onCreate (savedInstanceState );
// If the Intent Action is the Action for creating a real-time folder
If (getIntent (). getAction (). equals (LiveFolders. ACTION_CREATE_LIVE_FOLDER )){
Intent intent = new Intent ();
// Set the uri of the data provided by ContentProvider displayed in the real-time folder
Intent. setData (Uri. parse ("content: // org. crazyit. providers. dictprovider/words "));
// Set the base intent attribute of the real-time folder
Intent. putExtra (LiveFolders. EXTRA_LIVE_FOLDER_BASE_INTENT, new Intent (Intent. ACTION_VIEW
, Uri. parse ("content: // org. crazyit. providers. dictprovider/word /")));
// Set the Real-Time folder name
Intent. putExtra (LiveFolders. EXTRA_LIVE_FOLDER_NAME, "term ");
// Set the icon of the real-time folder
Intent. putExtra (LiveFolders. EXTRA_LIVE_FOLDER_ICON, Intent. Reset cuticonresource. fromContext (this, R. drawable. ic_launcher ));
// Set the display mode of the real-time folder
Intent. putExtra (LiveFolders. EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders. DISPLAY_MODE_GRID );
SetResult (RESULT_ OK, intent );
}
Else {
SetResult (RESULT_CANCELED );
}
// End the Activity
Finish ();
}
}

Package org. wwj. desktop;

Import android. app. Activity;
Import android. content. Intent;
Import android.net. Uri;
Import android. OS. Bundle;
Import android. provider. LiveFolders;

Public class WordsLiveFolder extends Activity {
@ Override
Protected void onCreate (Bundle savedInstanceState ){
// TODO Auto-generated method stub
Super. onCreate (savedInstanceState );
// If the Intent Action is the Action for creating a real-time folder
If (getIntent (). getAction (). equals (LiveFolders. ACTION_CREATE_LIVE_FOLDER )){
Intent intent = new Intent ();
// Set the uri of the data provided by ContentProvider displayed in the real-time folder
Intent. setData (Uri. parse ("content: // org. crazyit. providers. dictprovider/words "));
// Set the base intent attribute of the real-time folder
Intent. putExtra (LiveFolders. EXTRA_LIVE_FOLDER_BASE_INTENT, new Intent (Intent. ACTION_VIEW
, Uri. parse ("content: // org. crazyit. providers. dictprovider/word /")));
// Set the Real-Time folder name
Intent. putExtra (LiveFolders. EXTRA_LIVE_FOLDER_NAME, "term ");
// Set the icon of the real-time folder
Intent. putExtra (LiveFolders. EXTRA_LIVE_FOLDER_ICON, Intent. Reset cuticonresource. fromContext (this, R. drawable. ic_launcher ));
// Set the display mode of the real-time folder
Intent. putExtra (LiveFolders. EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders. DISPLAY_MODE_GRID );
SetResult (RESULT_ OK, intent );
}
Else {
SetResult (RESULT_CANCELED );
}
// End the Activity
Finish ();
}
}
 

[Html]

<Activity android: name = ". WordsLiveFolder"
Android: label = "@ string/app_name">
<Intent-filter>
<Action android: name = "android. intent. action. CREATE_LIVE_FOLDER"/>
<Category android: name = "android. intent. category. DEFAULT"/>
</Intent-filter>
</Activity>


<Activity android: name = ". WordsLiveFolder"
Android: label = "@ string/app_name">
<Intent-filter>
<Action android: name = "android. intent. action. CREATE_LIVE_FOLDER"/>
<Category android: name = "android. intent. category. DEFAULT"/>
</Intent-filter>
</Activity>
 

 

[Java]
Package org. wwj. desktop;
 
Import android. app. Activity;
Import android. content. ContentUris;
Import android. database. Cursor;
Import android.net. Uri;
Import android. OS. Bundle;
Import android. widget. EditText;
 
Public class ShowWordActivity extends Activity
{
EditText etWord, etDescription;
@ Override
Public void onCreate (Bundle savedInstanceState)
{
Super. onCreate (savedInstanceState );
SetContentView (R. layout. show );
// Obtain interface components
EtWord = (EditText) findViewById (R. id. word );
EtDescription = (EditText) findViewById (R. id. description );
Uri uri = getIntent (). getData ();
// Obtain the Word ID
Long id = ContentUris. parseId (uri );
// Query the specified word from ContentProvider
Cursor cursor = getContentResolver (). query (
Uri. parse ("content: // org. crazyit. providers. dictprovider/words ")
, Null, "_ id =? ", New String [] {id +" "}, null );
If (cursor. moveToNext ())
{
// Use the interface component to display the query results
EtWord. setText (cursor. getString (1 ));
EtDescription. setText (cursor. getString (2 ));
}
}
}

Package org. wwj. desktop;

Import android. app. Activity;
Import android. content. ContentUris;
Import android. database. Cursor;
Import android.net. Uri;
Import android. OS. Bundle;
Import android. widget. EditText;

Public class ShowWordActivity extends Activity
{
EditText etWord, etDescription;
@ Override
Public void onCreate (Bundle savedInstanceState)
{
Super. onCreate (savedInstanceState );
SetContentView (R. layout. show );
// Obtain interface components
EtWord = (EditText) findViewById (R. id. word );
EtDescription = (EditText) findViewById (R. id. description );
Uri uri = getIntent (). getData ();
// Obtain the Word ID
Long id = ContentUris. parseId (uri );
// Query the specified word from ContentProvider
Cursor cursor = getContentResolver (). query (
Uri. parse ("content: // org. crazyit. providers. dictprovider/words ")
, Null, "_ id =? ", New String [] {id +" "}, null );
If (cursor. moveToNext ())
{
// Use the interface component to display the query results
EtWord. setText (cursor. getString (1 ));
EtDescription. setText (cursor. getString (2 ));
}
}
}
 

[Html]
<Activity
Android: name = ". ShowWordActivity"
Android: label = "@ string/title_activity_show_word">
<Intent-filter>
<Action android: name = "android. intent. action. VIEW"/>
<Category android: name = "android. intent. category. DEFAULT"/>
<Data android: mimeType = "vnd. android. cursor. item/org. crazyit. dict"/>
</Intent-filter>
</Activity>

<Activity
Android: name = ". ShowWordActivity"
Android: label = "@ string/title_activity_show_word">
<Intent-filter>
<Action android: name = "android. intent. action. VIEW"/>
<Category android: name = "android. intent. category. DEFAULT"/>
<Data android: mimeType = "vnd. android. cursor. item/org. crazyit. dict"/>
</Intent-filter>
</Activity>
 

[Html]
<? Xml version = "1.0" encoding = "UTF-8"?>
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
>
<TextView
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/word"
/>
<EditText
Android: id = "@ + id/word"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: cursorVisible = "false"
Android: editable = "false"
/>
<TextView
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/description"
/>
<EditText
Android: id = "@ + id/description"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: lines = "3"
Android: cursorVisible = "false"
Android: editable = "false"
/>
</LinearLayout>

<? Xml version = "1.0" encoding = "UTF-8"?>
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
>
<TextView
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/word"
/>
<EditText
Android: id = "@ + id/word"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: cursorVisible = "false"
Android: editable = "false"
/>
<TextView
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/description"
/>
<EditText
Android: id = "@ + id/description"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: lines = "3"
Android: cursorVisible = "false"
Android: editable = "false"
/>
</LinearLayout>
 

Author: wwj_748
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.