Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create folder on home screen programmatically?

I am creating one application in which I requirement to create a folder on home screen. And user can able to drop some app icons to it. Is it possible? If yes then Can any one please tell me how to create folder...

I Try This

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;
        }
}

Manifest

    <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>
like image 289
Karan Mavadhiya Avatar asked Mar 01 '14 15:03

Karan Mavadhiya


Video Answer


1 Answers

Is it possible?

Not really.

First, not all home screens offer folders. There are dozens, perhaps hundreds, of home screen implementations that ship on devices, let alone third-party ones available through the Play Store and elsewhere.

Second, not all home screens that offer folders offer any sort of API to allow third-party apps to create such folders.

like image 197
CommonsWare Avatar answered Sep 21 '22 00:09

CommonsWare