zoukankan      html  css  js  c++  java
  • Android之创建实时文件夹

    以下使用的是SDK自带的例子来进行分析:

    首先,需要在 AndroidManifest.xml中添加<action android:name= "android.intent.action.CREATE_LIVE_FOLDER" />

    然后如下分析: 

    public class MyLiveFolder extends Activity {
         
    public static final Uri CONTENT_URI = Uri.parse("content://my.app/live");

         
    protected void onCreate(Bundle savedInstanceState) {
             
    super.onCreate(savedInstanceState);
    //获得Intent
             
    final Intent intent = getIntent(); //获得在AndroidManifest中设定的action
             
    final String action = intent.getAction();
    //判定
             
    if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
                 setResult
    (RESULT_OK, createLiveFolder(this, CONTENT_URI, "My LiveFolder",
                         R
    .drawable.ic_launcher_contacts_phones));
             
    } else {
                 setResult
    (RESULT_CANCELED);
             
    }

             finish
    ();
         
    }

         
    private static Intent createLiveFolder(Context context, Uri uri, String name,
                 
    int icon) {

             
    final Intent intent = new Intent();
    //设置数据地址
             intent
    .setData(uri); //设置实时文件夹的名字
             intent
    .putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, name); //设置实时文件夹的图片
             intent
    .putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,
                     
    Intent.ShortcutIconResource.fromContext(context, icon)); //设置实时文件夹得显示模式,一种是列表模式,另一种是类型于九宫格的模式
             intent
    .putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_LIST);

             
    return intent;
         
    }
     
    }

      

  • 相关阅读:
    [CF895C]Square Subsets
    Brainf**k(一位数求max)
    [CF1019A]Elections
    [LOJ #2538][PKUWC 2018]Slay the Spire
    [CF911F]Tree Destruction
    [bzoj4832][Lydsy1704月赛]抵制克苏恩
    [洛谷P1420]最长连号
    [bzoj4872][Shoi2017]分手是祝愿
    [洛谷P1887]乘积最大3
    [洛谷P3743]kotori的设备
  • 原文地址:https://www.cnblogs.com/lee0oo0/p/2475190.html
Copyright © 2011-2022 走看看