Android 在launcher中建立即時檔案夾【安卓進化三十三】

來源:互聯網
上載者:User

               最近看了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>

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.