2017-04-14 87 views

回答

0

嘗試使用裝載機

退房以下的答案對我來說

String DISPLAY_NAME = ContactsContract.Contacts.DISPLAY_NAME; 
    String NUMBER = ContactsContract.CommonDataKinds.Phone.NUMBER; 


public class SmsInviteFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> { 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 
    View v = inflater.inflate(R.layout.fragment_sms_invite, container, false); 

    getActivity().getSupportLoaderManager().initLoader(1, null, SmsInviteFragment.this); 
    return v; 

} 





@Override 
    public Loader<Cursor> onCreateLoader(int id, Bundle args) { 
     onStartNetCall(); 
     Uri CONTENT_URI = ContactsContract.CommonDataKinds.Phone.CONTENT_URI; 

    return new CursorLoader(getActivity(), CONTENT_URI, null, null, null, null); 
} 

public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) { 

    cursor.moveToFirst(); 
    while (!cursor.isAfterLast()) { 


     String name = "" + cursor.getString(cursor.getColumnIndex(DISPLAY_NAME)); 
     String phoneNo = "" + cursor.getString(cursor.getColumnIndex(NUMBER)); 


     cursor.moveToNext(); 


    } 

    Log.e(TAG, "onLoadFinished: "); 


} 

@Override 
public void onLoaderReset(Loader<Cursor> loader) { 

} 

} 
工作
相關問題