Java Code Examples for android.content.CursorLoader

The following are top voted examples for showing how to use android.content.CursorLoader. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ActivityDiary   File: HistoryActivity.java   View source code 6 votes vote down vote up
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    if(id == LOADER_ID_HISTORY) {
        return new CursorLoader(this, ActivityDiaryContract.Diary.CONTENT_URI,
                PROJECTION, SELECTION, null, null);
    }else{

        return new CursorLoader(HistoryActivity.this,
                ActivityDiaryContract.DiaryImage.CONTENT_URI,
                new String[] {ActivityDiaryContract.DiaryImage._ID,
                        ActivityDiaryContract.DiaryImage.URI},
                ActivityDiaryContract.DiaryImage.DIARY_ID + "=? AND "
                        + ActivityDiaryContract.DiaryImage._DELETED + "=0",
                new String[] {Long.toString(args.getLong("DiaryID"))},
                null);
    }
}
 
Example 2
Project: GitHub   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 3
Project: GSB-2017-Android   File: DummyLoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 4
Project: NewsApp   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 5
Project: 19porn   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 6
Project: FlashCards   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 7
Project: Chore-Manager-App   File: AppLoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 8
Project: labtablet   File: FileMgr.java   View source code 6 votes vote down vote up
@SuppressLint("NewApi")
public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    String result = null;

    CursorLoader cursorLoader = new CursorLoader(
            context,
            contentUri, proj, null, null, null);
    Cursor cursor = cursorLoader.loadInBackground();

    if(cursor != null){
        int column_index =
                cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        result = cursor.getString(column_index);
    }
    return result;
}
 
Example 9
Project: atlas   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 10
Project: FastAndroid   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 11
Project: pets   File: CatalogActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    String[] projection = {
            PetEntry._ID,
            PetEntry.COLUMN_NAME,
            PetEntry.COLUMN_BREED
    };

    return new CursorLoader(
            this,
            PetEntry.CONTENT_URI,
            projection,
            null,
            null,
            null);
}
 
Example 12
Project: pets   File: EditorActivity.java   View source code 6 votes vote down vote up
/**
 *
 * @param id
 * @param args
 * @return
 */
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    String[] projection = {
            PetEntry._ID,
            PetEntry.COLUMN_NAME,
            PetEntry.COLUMN_BREED,
            PetEntry.COLUMN_GENDER,
            PetEntry.COLUMN_WEIGHT
    };

    return new CursorLoader(
            this,
            uriCurrentPet,
            projection,
            null,
            null,
            null);
}
 
Example 13
Project: changApp   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 14
Project: maklib   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 15
Project: Book-Tea_Project   File: RegisterActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 16
Project: Paathshala   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {

    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 17
Project: Paathshala   File: SignUp.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 18
Project: ShotsNewsApp   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 19
Project: KTools   File: ContactsLoaderCallback.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    //指定获取_id和display_name两列数据,display_name即为姓名
    String[] projection = new String[]{
            ContactsContract.Contacts._ID,
            ContactsContract.Contacts.DISPLAY_NAME
    };
    CursorLoader loader = new CursorLoader(
            context,
            ContactsContract.Contacts.CONTENT_URI,
            projection,
            null,
            null,
            null
    );
    return loader;
}
 
Example 20
Project: study-buddy   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 21
Project: iosched-reader   File: SessionFeedbackModelTest.java   View source code 6 votes vote down vote up
@Test
public void createCursorLoader_SessionQuery_Success() {
    // Given a mock cursor loader set up for a session query
    int sessionsLoaderId = SessionFeedbackModel.SessionFeedbackQueryEnum.SESSION.getId();

    CursorLoader mockCursorLoaderSession = mock(CursorLoader.class);

    SessionFeedbackModel spyModel = spy(
            new SessionFeedbackModel(mMockUri, mMockContext, mMockFeedbackHelper));

    doReturn(mockCursorLoaderSession).when(spyModel).getCursorLoaderInstance(
            any(Context.class), any(Uri.class), any(String[].class), any(String.class),
            any(String[].class), any(String.class));

    // When ran with the session query
    CursorLoader createdCursorLoader1 =
            (CursorLoader) spyModel.createCursorLoader(sessionsLoaderId, mMockUri, null);

    // Then the returned cursor loader is the same as the mock one
    assertThat(createdCursorLoader1, sameInstance(mockCursorLoaderSession));
}
 
Example 22
Project: iosched-reader   File: SessionDetailModelTest.java   View source code 6 votes vote down vote up
@Test
public void createCursorLoader_SpeakersQuery_ReturnsCursor() {
    // Given a mock uri and mock cursor loader
    SessionDetailModel spyModel = spy(
            new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper));
    doReturn(mMockUri).when(spyModel).getSpeakersDirUri(any(String.class));
    doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(
            any(Context.class), any(Uri.class), any(String[].class), any(String.class),
            any(String[].class), any(String.class));

    // When ran with mock uri and speakers query loader id
    CursorLoader createdCursorLoader =
            (CursorLoader) spyModel.createCursorLoader(
                    SessionDetailModel.SessionDetailQueryEnum.SPEAKERS.getId(),
                    mMockUri, null);

    // Then the returned cursor loader is the mock cursor loader
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
 
Example 23
Project: iosched-reader   File: SessionDetailModelTest.java   View source code 6 votes vote down vote up
@Test
public void createCursorLoader_FeedbackQuery_ReturnsCursor() {
    // Given a mock uri and mock cursor loader
    SessionDetailModel spyModel = spy(
            new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper));
    doReturn(mMockUri).when(spyModel).getFeedbackUri(any(String.class));
    doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(
            any(Context.class), any(Uri.class), any(String[].class), any(String.class),
            any(String[].class), any(String.class));

    // When ran with mock uri and feedback query loader id
    CursorLoader createdCursorLoader =
            (CursorLoader) spyModel.createCursorLoader(
                    SessionDetailModel.SessionDetailQueryEnum.FEEDBACK.getId(),
                    mMockUri, null);

    // Then the returned cursor loader is the mock cursor loader
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
 
Example 24
Project: iosched-reader   File: VideoLibraryModelTest.java   View source code 6 votes vote down vote up
@Test
public void createCursorLoader_FilteredVideosQuery_Success() {
    // Given a mock cursor loader set up for a video query
    int videosLoaderId = VideoLibraryModel.VideoLibraryQueryEnum.VIDEOS.getId();

    when(mMockBundle.containsKey(VideoLibraryModel.KEY_TOPIC)).thenReturn(true);
    when(mMockBundle.containsKey(VideoLibraryModel.KEY_YEAR)).thenReturn(true);
    when(mMockBundle.getString(VideoLibraryModel.KEY_TOPIC)).thenReturn("Android");
    when(mMockBundle.getInt(VideoLibraryModel.KEY_YEAR)).thenReturn(2012);

    // When ran with the video query
    CursorLoader createdCursorLoader =
            (CursorLoader) mSpyModel.createCursorLoader(videosLoaderId, Uri.EMPTY, mMockBundle);

    // Then the returned cursor loader is the same as the mock one
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
 
Example 25
Project: localcloud_fe   File: FileHelper.java   View source code 6 votes vote down vote up
@SuppressLint("NewApi")
public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    String result = null;

    try {
        CursorLoader cursorLoader = new CursorLoader(context, contentUri, proj, null, null, null);
        Cursor cursor = cursorLoader.loadInBackground();

        if (cursor != null) {
            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            result = cursor.getString(column_index);
        }
    } catch (Exception e) {
        result = null;
    }
    return result;
}
 
Example 26
Project: AndroidApp-Deploy   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 27
Project: programming   File: Login.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 28
Project: dapay   File: Login_BT_Activity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 29
Project: Shared-Route   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 30
Project: Shared-Route   File: PayBillActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 31
Project: Shared-Route   File: RegisterActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), RegisterActivity.ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 32
Project: Shared-Route   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 33
Project: BestBlog   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
Example 34
Project: aos-MediaLib   File: IndexHelper.java   View source code 6 votes vote down vote up
public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) {
    if (loaderID == mLoaderManagerId && (mUri != null || mVideoId != -1)) {
        String selection = (mVideoId != -1 ? BaseColumns._ID : MediaColumns.DATA) + "=?";
        if(LoaderUtils.mustHideUserHiddenObjects())
            selection += " AND "+LoaderUtils.HIDE_USER_HIDDEN_FILTER;
        CursorLoader cursorLoader =  new CursorLoader(
                mContext,
                VideoStore.Video.Media.EXTERNAL_CONTENT_URI,
                VideoDbInfo.COLUMNS,selection
                 ,
                new String [] {(mVideoId != -1 ? String.valueOf(mVideoId) : mUri.toString())},
                null);
        if(mLoaderManager==null)
            cursorLoader.registerListener(loaderID, this);
        return cursorLoader;
    }
    return null;
}
 
Example 35
Project: EasyEmoji   File: ImageModel.java   View source code 5 votes vote down vote up
@Override
public android.support.v4.content.Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new android.support.v4.content.CursorLoader( mContext,
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
            IMAGE_PROJECTION,
            "",
            null,
            IMAGE_PROJECTION[2] + " DESC");
}
 
Example 36
Project: publicProject   File: ImageUtils.java   View source code 5 votes vote down vote up
/**
 * 根据uri获取图片路径
 *
 * @param mContext
 * @param contentUri
 * @return
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static String getPathFromUri(Context mContext, Uri contentUri) {
    String[] proj = {MediaStore.Images.Media.DATA};
    CursorLoader loader = new CursorLoader(mContext, contentUri, proj, null, null, null);
    Cursor cursor = loader.loadInBackground();
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}
 
Example 37
Project: android-ContentProviderPaging   File: ImageClientFragment.java   View source code 5 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    final Activity activity = ImageClientFragment.this.getActivity();
    return new CursorLoader(activity) {
        @Override
        public Cursor loadInBackground() {
            Bundle bundle = new Bundle();
            bundle.putInt(ContentResolver.QUERY_ARG_OFFSET, mOffset.intValue());
            bundle.putInt(ContentResolver.QUERY_ARG_LIMIT, LIMIT);
            return activity.getContentResolver()
                    .query(ImageContract.CONTENT_URI, null, bundle, null);
        }
    };
}
 
Example 38
Project: AndroidSdrRtlTuner   File: SettingsFragment.java   View source code 5 votes vote down vote up
/**
 * Extract the path from an uri
 * This code was published on StackOverflow by dextor
 *
 * @param contentUri		uri that contains the file path
 * @return absolute file path as string
 */
private String getRealPathFromURI(Uri contentUri) {
	String[] proj = { MediaStore.Images.Media.DATA };
	CursorLoader loader = new CursorLoader(this.getActivity(), contentUri, proj, null, null, null);
	Cursor cursor = loader.loadInBackground();
	int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
	cursor.moveToFirst();
	return cursor.getString(column_index);
}
 
Example 39
Project: CodeWatch   File: ProfileActivity.java   View source code 5 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(this,
            LeaderContract.LeaderEntry.buildProfileUri(userId),
            null,
            null,
            null,
            null);
}
 
Example 40
Project: CodeWatch   File: NavigationDrawerActivity.java   View source code 5 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(this,
            LeaderContract.LeaderEntry.buildProfileUri(getWakatimeUid()),
            null,
            null,
            null,
            null);
}