Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
import android.Manifest;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
import java.net.URI;
import java.util.ArrayList;
public class Contact extends AppCompatActivity implements View.OnClickListener{
private static final String TAG = Contact.class.getSimpleName();
private Button add, read;
ListView listview;
private TextView listview1;
private static final int PERMISSIONS_REQUEST_READ_CONTACTS = 100;
ArrayList<String> contacts;
String id, nama, nomer;
ArrayAdapter<CharSequence> adapter;
ArrayList<String> mArrayList;
ArrayAdapter<String> mAdapter;
int i=0;
Cursor cursor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contact);
add=(Button) findViewById(R.id.add);
read=(Button) findViewById(R.id.read);
listview=(ListView) findViewById(R.id.listview);
listview1 = (TextView)findViewById(R.id.txt);
ContentResolver resolver = getContentResolver();
cursor = resolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
while (cursor.moveToNext()){
id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
nama = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
Cursor phoneCursor = resolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=?", new String[]{id}, null);
while (phoneCursor.moveToNext()){
nomer = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
}
add.setOnClickListener(this);
read.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.add:
Intent add=new Intent(Contact.this,saveContact.class);
startActivity(add);
finish();
break;
case R.id.read:
// cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
// startManagingCursor(cursor);
//String contactName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
//String contactNumber = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
String[] list = {"Nama : "+nama + "n"+"Nomer : " +nomer};
//2.inisiasi ArrayList sebagai wadah dari List kita
//mArrayList = new ArrayList<String>();
//3.Inisiasi Adapter
// mAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,mArrayList);
//4.Set Adapter
//listview.setAdapter(mAdapter);
//5.Coba isi data
// mArrayList.add("nama: " + nama + "n" + "nomer: " + nomer);
// String[] list = {"Rian", "Rakhmad", "Faisal", "Ramdani", "Azzat", "Oktavian"};
//int [] to = {android.R.id.text1,android.R.id.text2};
//SimpleCursorAdapter listadapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, list, to);
//listview.setAdapter(listadapter);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
listview.setAdapter(adapter);
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent sms = new Intent(getBaseContext(), sms.class);
sms.putExtra("no", nomer);
startActivityForResult(sms, 2);
}
});
break;
}
}
//batas
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team