mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
Work on contacts
This commit is contained in:
parent
25ff4b0eba
commit
7ead5ec2d8
@ -13,6 +13,8 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
||||
android:debuggable="true">
|
||||
|
@ -87,6 +87,11 @@
|
||||
alert(fail);
|
||||
}
|
||||
|
||||
function foo()
|
||||
{
|
||||
ContactHook.findContacts();
|
||||
}
|
||||
|
||||
function init(){
|
||||
document.addEventListener("touchmove", preventBehavior, false);
|
||||
setTimeout(deviceInfo, 1);
|
||||
@ -112,7 +117,8 @@
|
||||
<a href="tel://411" class="btn large">Call 411</a>
|
||||
<a href="#" class="btn" onclick="beep();">Beep</a>
|
||||
<a href="#" class="btn" onclick="vibrate();">Vibrate</a>
|
||||
<a href="#" class="btn large" onclick="show_pic();">Get a Picture</a>
|
||||
<a href="#" class="btn" onclick="show_pic();">Get a Picture</a>
|
||||
<a href="#" class="btn" onclick="foo();">Fire Contact Code</a>
|
||||
<div id="viewport" class="viewport">
|
||||
<img style="width:60px;height:60px" id="test_img" src="" />
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="PhoneGap" default="help">
|
||||
<project name="PhoneGap">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contain the path to the SDK. It should *NOT* be checked in in Version
|
||||
|
@ -7,16 +7,8 @@
|
||||
# "build.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=Google Inc.:Google APIs:3
|
||||
# apk configurations. This property allows creation of APK files with limited
|
||||
# resources. For example, if your application contains many locales and
|
||||
# you wish to release multiple smaller apks instead of a large one, you can
|
||||
# define configuration to create apks with limited language sets.
|
||||
# Format is a comma separated list of configuration names. For each
|
||||
# configuration, a property will declare the resource configurations to
|
||||
# include. Example:
|
||||
# apk-configurations=european,northamerica
|
||||
# apk-config-european=en,fr,it,de,es
|
||||
# apk-config-northamerica=en,es
|
||||
apk-configurations=
|
||||
# Project target.
|
||||
target=android-4
|
||||
# Indicates whether an apk should be generated for each density.
|
||||
split.density=false
|
||||
|
@ -7,4 +7,4 @@
|
||||
# location of the SDK. This is only used by Ant
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
sdk-location=/home/bowserj/android-sdk-linux_x86-1.5_r3
|
||||
sdk-location=/home/bowserj/android-sdk-linux_x86-1.6_r1
|
||||
|
@ -1,43 +1,65 @@
|
||||
package com.phonegap.demo;
|
||||
|
||||
import android.provider.Contacts.People;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.net.Uri;
|
||||
import android.database.Cursor;
|
||||
|
||||
public class ContactManager {
|
||||
|
||||
public void grabContacts()
|
||||
{
|
||||
Uri people = android.provider.Contacts.People.CONTENT_URI;
|
||||
Uri phone = android.provider.Contacts.Phones.CONTENT_URI;
|
||||
}
|
||||
|
||||
Activity mApp;
|
||||
Uri mPeople = android.provider.Contacts.People.CONTENT_URI;
|
||||
Uri mPhone = android.provider.Contacts.Phones.CONTENT_URI;
|
||||
Uri mEmail = android.provider.Contacts.ContactMethods.CONTENT_EMAIL_URI;
|
||||
|
||||
ContactManager(Activity app)
|
||||
{
|
||||
mApp = app;
|
||||
}
|
||||
|
||||
private void getColumnData(Cursor cur){
|
||||
|
||||
ContentResolver cr = getContentResolver();
|
||||
|
||||
|
||||
ContentResolver cr = mApp.getContentResolver();
|
||||
|
||||
if (cur.moveToFirst()) {
|
||||
|
||||
String name;
|
||||
String phoneNumber;
|
||||
int nameColumn = cur.getColumnIndex(People.NAME);
|
||||
String email;
|
||||
String phoneNumber;
|
||||
int nameColumn = cur.getColumnIndex(People.NAME);
|
||||
int phoneColumn = cur.getColumnIndex(People.NUMBER);
|
||||
String imagePath;
|
||||
|
||||
do {
|
||||
// Get the field values
|
||||
name = cur.getString(nameColumn);
|
||||
name = cur.getString(nameColumn);
|
||||
phoneNumber = cur.getString(phoneColumn);
|
||||
|
||||
|
||||
|
||||
|
||||
} while (cur.moveToNext());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void findContacts()
|
||||
{
|
||||
|
||||
// Form an array specifying which columns to return.
|
||||
String[] projection = new String[] {
|
||||
People._ID,
|
||||
People.NAME,
|
||||
People.NUMBER
|
||||
};
|
||||
|
||||
// Make the query.
|
||||
Cursor managedCursor = mApp.managedQuery(mPeople,
|
||||
projection, // Which columns to return
|
||||
null, // Which rows to return (all rows)
|
||||
null, // Selection arguments (none)
|
||||
// Put the results in ascending order by name
|
||||
People.DISPLAY_NAME + " ASC");
|
||||
|
||||
this.getColumnData(managedCursor);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public class DroidGap extends Activity {
|
||||
private GeoBroker geo;
|
||||
private AccelListener accel;
|
||||
private CameraLauncher launcher;
|
||||
private ContactManager mContacts;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
@ -98,11 +99,13 @@ public class DroidGap extends Activity {
|
||||
geo = new GeoBroker(appView, this);
|
||||
accel = new AccelListener(this, appView);
|
||||
launcher = new CameraLauncher(appView, this);
|
||||
mContacts = new ContactManager(this);
|
||||
// This creates the new javascript interfaces for PhoneGap
|
||||
appView.addJavascriptInterface(gap, "DroidGap");
|
||||
appView.addJavascriptInterface(geo, "Geo");
|
||||
appView.addJavascriptInterface(accel, "Accel");
|
||||
appView.addJavascriptInterface(launcher, "GapCam");
|
||||
appView.addJavascriptInterface(mContacts, "ContactHook");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user