android学习之实时文件夹的创建?public class Activity01 extends Activity{public void onCreate(Bundle
android学习之实时文件夹的创建
?public class Activity01 extends Activity{public void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);// setContentView(R.layout.main);// 判断是否创建实时文件夹if (getIntent().getAction().equals(LiveFolders.ACTION_CREATE_LIVE_FOLDER)){Intent intent = new Intent();// 设置数据地址intent.setData(Uri.parse("content://contacts/live_folders/people"));// 设置当我们单击之后的事件,这里单击一个联系人后,呼叫intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT, new Intent(Intent.ACTION_CALL, ContactsContract.Contacts.CONTENT_URI));// 设置实时文件夹的名字intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, "电话本");// 设置实施文件夹的图标intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON, Intent.ShortcutIconResource.fromContext(this, R.drawable.contacts));// 设置显示模式为列表intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_LIST);// 完成setResult(RESULT_OK, intent);}else{setResult(RESULT_CANCELED);}finish();}}?在mainfest.xml中的配置:
?
?
?<activity android:name=".Activity01"
????????????????? 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>
?
需要在主页面中按menu键,然后点击添加文件夹的方式添加实时文件夹
