当前位置:操作系统 > 安卓/Android >>

Android-管理Android手机桌面

Android-管理Android手机桌面

没有接触手机编程之前,我就很好奇,那些主题背景和动态壁纸是如何做出来的,如何把图标放到手机桌面上,学习了关于管理Android手机桌面之后,我大致了解了这些内容,算是扫了一下盲了。

我相信只要用过一段Android系统手机的用户,对于手机桌面的操作是非常明了的。比如删除桌面组件,添加相应的组件到桌面这些简单的操作。

关于手机桌面的这部分内容,我自己学习了如何开发实时壁纸(Live Wallpapers),如何在桌面上创建快捷方式,管理桌面小控件,如何开发实时文件夹(LiveFolder)等。

 

下面是一个显示生词本的实时文件夹的实例

这个实时文件夹显示ContentProvider的数据,这要把之前开发DictProvider部署到模拟器中,才可以用实时文件显示ContentProvider返回的数据

 

创建项目:WordsLiveFolder

运行项目效果:

    

 \

       \
 

\        \

 

\      \

 

     

 

[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); 
        //如果该Intent的Action是创建实时文件夹的Action  
        if(getIntent().getAction().equals(LiveFolders.ACTION_CREATE_LIVE_FOLDER)){ 
            Intent intent = new Intent(); 
            //设置实时文件夹所显示ContentProvider提供的数据的uri  
            intent.setData(Uri.parse("content://org.crazyit.providers.dictprovider/words")); 
            //设置实时文件夹的base intent属性  
            intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT, new Intent(Intent.ACTION_VIEW 
                    , Uri.parse("content://org.crazyit.providers.dictprovider/word/"))); 
            //设置实时文件夹的名称  
            intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, "生词本"); 
            //设置实时文件夹的图标  
            intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher)); 
            //设置实时文件夹的显示模式  
            intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_GRID); 
            setResult(RESULT_OK, intent); 
        } 
        else{ 
            setResult(RESULT_CANCELED); 
        } 
        //结束该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);
  //如果该Intent的Action是创建实时文件夹的Action
  if(getIntent().getAction().equals(LiveFolders.ACTION_CREATE_LIVE_FOLDER)){
   Intent intent = new Intent();
   //设置实时文件夹所显示ContentProvider提供的数据的uri
   intent.setData(Uri.parse("content://org.crazyit.providers.dictprovider/words"));
   //设置实时文件夹的base intent属性
   intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT, new Intent(Intent.ACTION_VIEW
     , Uri.parse("content://org.crazyit.providers.dictprovider/word/")));
   //设置实时文件夹的名称
   intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, "生词本");
   //设置实时文件夹的图标
   intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher));
   //设置实时文件夹的显示模式
   intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_GRID);
   setResult(RESULT_OK, intent);
  }
  else{
   setResult(RESULT_CANCELED);
  }
  //结束该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"/>
            &n

补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,