我正在创建一个应用程序,我需要在其中在主屏幕上创建一个文件夹。并且用户可以将一些应用程序图标拖放到它上面。可能吗?如果是,那么谁能告诉我如何创建文件夹...
我试试这个
public class LiveFolderActivity extends Activity {
public static final Uri CONTENT_URI = Uri.parse("content://shelves/live_folders/books");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_live_folder);
final Intent intent = getIntent();
final String action = intent.getAction();
if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
setResult(RESULT_OK, createLiveFolder(this, CONTENT_URI,"Books", R.drawable.ic_launcher));
} 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;
}
}
list
<activity
android:name="com.example.testcreatefolder.LiveFolderActivity"
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>
最佳答案
Is it possible?
不是真的。
首先,并非所有主屏幕都提供文件夹。设备上有数十种甚至数百种主屏幕实现,更不用说通过 Play 商店和其他地方提供的第三方实现了。
其次,并非所有提供文件夹的主屏幕都提供任何类型的 API 以允许第三方应用程序创建此类文件夹。
关于android - 以编程方式在主屏幕上创建文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22116399/