最近看了launcher方面的知識。在launcher中,選擇檔案夾選項後,選擇“大明通訊錄”就在主介面的launcher中建立了個即時檔案夾,能調出連絡人的姓名來,然後我們可以對其進行處理,點擊進入手機號碼的內容,然後可以打電話操作等等其他的操作!說明一下:即時檔案夾顯示有兩種方式,一種是列表形式:DISPLAY_MODE_LIST。令一種是宮格的形式:DISPLAY_MODE_GRID。別忘了在Manifest.xml中註冊一下:
<intent-filter> <action android:name="android.intent.action.CREATE_LIVE_FOLDER"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter>
轉載請標明出處:http://blog.csdn.net/wdaming1986/article/details/6878873
下面看:
長按主菜單螢幕彈出這個對話方塊: 點擊大明通訊錄選項:
主介面多了個通訊錄的即時檔案夾: 以list形式顯示通訊錄的內容:
以grid形式顯示通訊錄的內容:
下面看代碼:TempFileWidget程式:
一、在com.cn.daming的包下面的TempFileWidgetMainActivity.java類中的代碼:
package com.cn.daming;import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.provider.ContactsContract;import android.provider.LiveFolders;import android.widget.Toast;public class TempFileWidgetMainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //charge the floder is refresh floder or not if(getIntent().getAction().equals(LiveFolders.ACTION_CREATE_LIVE_FOLDER)){Intent mIntent = new Intent();mIntent.setData(Uri.parse("content://contacts/live_folders/people"));new Intent(Intent.ACTION_VIEW,ContactsContract.Contacts.CONTENT_URI);mIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, "通訊錄");mIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,Intent.ShortcutIconResource.fromContext(this, R.drawable.contacts));//list modemIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_LIST);//grid mode//mIntent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_GRID);setResult(RESULT_OK, mIntent);}else{setResult(RESULT_CANCELED);} finish(); }}
二、在AndroidManifest.xml中的代碼:
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cn.daming" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/contacts" android:label="@string/app_name"> <activity android:name=".TempFileWidgetMainActivity" android:label="@string/app_name"> <!-- add the contacts widget launcher --> <intent-filter> <action android:name="android.intent.action.CREATE_LIVE_FOLDER"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> </application></manifest>
三、values包下string中的代碼:
<?xml version="1.0" encoding="utf-8"?><resources> <string name="hello">Hello World, TempFileWidgetMainActivity!</string> <string name="app_name">大明通訊錄</string></resources>