Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 15, 2016
0 parents commit feec376
Show file tree
Hide file tree
Showing 194 changed files with 1,592 additions and 0 deletions.
Binary file added 9781430234463.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,27 @@
Freeware License, some rights reserved

Copyright (c) 2011 Wallace Jackson

Permission is hereby granted, free of charge, to anyone obtaining a copy
of this software and associated documentation files (the "Software"),
to work with the Software within the limits of freeware distribution and fair use.
This includes the rights to use, copy, and modify the Software for personal use.
Users are also allowed and encouraged to submit corrections and modifications
to the Software for the benefit of other users.

It is not allowed to reuse, modify, or redistribute the Software for
commercial use in any way, or for a user�s educational materials such as books
or blog articles without prior permission from the copyright holder.

The above copyright notice and this permission notice need to be included
in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


7 changes: 7 additions & 0 deletions Projects/Chapter10/.classpath
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
</classpath>
33 changes: 33 additions & 0 deletions Projects/Chapter10/.project
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Chapter10</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
5 changes: 5 additions & 0 deletions Projects/Chapter10/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
#Sat Nov 06 20:17:45 PDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.source=1.5
18 changes: 18 additions & 0 deletions Projects/Chapter10/AndroidManifest.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="content.providers"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".DatabaseExamples"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>
</manifest>
Binary file added Projects/Chapter10/bin/Chapter10.apk
Binary file not shown.
Binary file added Projects/Chapter10/bin/classes.dex
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Projects/Chapter10/bin/content/providers/R$id.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Projects/Chapter10/bin/content/providers/R.class
Binary file not shown.
Binary file added Projects/Chapter10/bin/resources.ap_
Binary file not shown.
11 changes: 11 additions & 0 deletions Projects/Chapter10/default.properties
@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-3
29 changes: 29 additions & 0 deletions Projects/Chapter10/gen/content/providers/R.java
@@ -0,0 +1,29 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package content.providers;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int addContactButton=0x7f050001;
public static final int deleteContactButton=0x7f050003;
public static final int modifyPhoneButton=0x7f050002;
public static final int queryButton=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
Binary file added Projects/Chapter10/res/drawable/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions Projects/Chapter10/res/layout/main.xml
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click Buttons Below to Query, Add, Modify, Delete"
android:paddingTop="25dip"
android:paddingBottom="50dip"/>
<Button android:text="Click to Query Contacts Database"
android:id="@+id/queryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<Button android:text="Click to Add A Contact to the Database"
android:id="@+id/addContactButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<Button android:text="Click to Modify the Contact in the Database"
android:id="@+id/modifyPhoneButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<Button android:text="Click to Delete the Contact in the Database"
android:id="@+id/deleteContactButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
5 changes: 5 additions & 0 deletions Projects/Chapter10/res/values/strings.xml
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, DatabaseExamples!</string>
<string name="app_name">Android Content Providers</string>
</resources>
91 changes: 91 additions & 0 deletions Projects/Chapter10/src/content/providers/DatabaseExamples.java
@@ -0,0 +1,91 @@
package content.providers;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.net.Uri;
import android.widget.Toast;
import android.database.Cursor;
import android.provider.Contacts.People;
import android.content.ContentValues;
public class DatabaseExamples extends Activity {
public Uri addUri = null;
public Uri changeUri = null;
@Override /** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button queryButton = (Button)findViewById(R.id.queryButton);
queryButton.setOnClickListener(new OnClickListener() {
public void onClick(View v){
queryContactPhoneNumber();
}
});
Button addButton = (Button)findViewById(R.id.addContactButton);
addButton.setOnClickListener(new OnClickListener() {
public void onClick(View v){
addContactPhoneNumber("Steve Wozniak", "415-555-7654");
}
});
Button modButton = (Button)findViewById(R.id.modifyPhoneButton);
modButton.setOnClickListener(new OnClickListener() {
public void onClick(View v){
modifyPhoneNumber("916-555-1234");
}
});
Button delButton = (Button)findViewById(R.id.deleteContactButton);
delButton.setOnClickListener(new OnClickListener() {
public void onClick(View v){
deleteContactPhoneNumber();
}
});
}
private void queryContactPhoneNumber() {
String[] cols = new String[] {People.NAME, People.NUMBER};
Uri myContacts = People.CONTENT_URI;
Cursor mqCur = managedQuery(myContacts,cols,null,null,null);
if (mqCur.moveToFirst()) {
String myname = null;
String mynumber = null;
do {
myname = mqCur.getString(mqCur.getColumnIndex(People.NAME));
mynumber = mqCur.getString(mqCur.getColumnIndex(People.NUMBER));
Toast.makeText(this, myname + " " + mynumber, Toast.LENGTH_SHORT).show();
} while (mqCur.moveToNext());
}
}
private void addContactPhoneNumber(String newName, String newPhone) {
ContentValues myContact = new ContentValues();
myContact.put(People.NAME, newName);
addUri = getContentResolver().insert(People.CONTENT_URI, myContact);
Uri contentUri = Uri.withAppendedPath(addUri, People.Phones.CONTENT_DIRECTORY);
myContact.clear();
myContact.put(People.Phones.TYPE, People.TYPE_MOBILE);
myContact.put(People.NUMBER, newPhone);
changeUri = getContentResolver().insert(contentUri, myContact);
Toast.makeText(this, "New Contact: " + newName + " " + newPhone, Toast.LENGTH_SHORT).show();
}
private void modifyPhoneNumber(String replacePhone) {
if (changeUri == null) {
Toast.makeText(this, "You need to create a new contact to update!", Toast.LENGTH_LONG).show();
} else {
ContentValues newPhoneNumber = new ContentValues();
newPhoneNumber.put(People.Phones.TYPE, People.TYPE_MOBILE);
newPhoneNumber.put(People.NUMBER, replacePhone);
getContentResolver().update(changeUri, newPhoneNumber, null,null);
Toast.makeText(this, "Updated phone number to: " + replacePhone, Toast.LENGTH_SHORT).show();
}
}
private void deleteContactPhoneNumber() {
if (changeUri == null) {
Toast.makeText(this, "You need to create a new contact to delete!", Toast.LENGTH_LONG).show();

} else {
getContentResolver().delete(addUri, null, null);
Toast.makeText(this, "Deleted contact at: " + addUri.toString(), Toast.LENGTH_SHORT).show();
addUri = null;
changeUri = null;
}
}
}
7 changes: 7 additions & 0 deletions Projects/Chapter11/.classpath
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
</classpath>
33 changes: 33 additions & 0 deletions Projects/Chapter11/.project
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Chapter11</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
19 changes: 19 additions & 0 deletions Projects/Chapter11/AndroidManifest.xml
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="Intent.Filters"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".IntentExamples"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DigitalClockActivity"></activity>
<service android:enabled="true" android:name=".MediaPlayerService" />
<receiver android:name=".timerBroadcastReceiver" android:enabled="true" />
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>
Binary file added Projects/Chapter11/bin/Chapter11.apk
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Projects/Chapter11/bin/Intent/Filters/R$attr.class
Binary file not shown.
Binary file not shown.
Binary file added Projects/Chapter11/bin/Intent/Filters/R$id.class
Binary file not shown.
Binary file added Projects/Chapter11/bin/Intent/Filters/R$layout.class
Binary file not shown.
Binary file added Projects/Chapter11/bin/Intent/Filters/R$raw.class
Binary file not shown.
Binary file added Projects/Chapter11/bin/Intent/Filters/R$string.class
Binary file not shown.
Binary file added Projects/Chapter11/bin/Intent/Filters/R.class
Binary file not shown.
Binary file not shown.
Binary file added Projects/Chapter11/bin/classes.dex
Binary file not shown.
Binary file added Projects/Chapter11/bin/resources.ap_
Binary file not shown.
11 changes: 11 additions & 0 deletions Projects/Chapter11/default.properties
@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-3
38 changes: 38 additions & 0 deletions Projects/Chapter11/gen/Intent/Filters/R.java
@@ -0,0 +1,38 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package Intent.Filters;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
public static final int image1=0x7f020001;
}
public static final class id {
public static final int AnalogClock01=0x7f060004;
public static final int Button01=0x7f060000;
public static final int DigitalClock01=0x7f060001;
public static final int startButton=0x7f060005;
public static final int startTimer=0x7f060003;
public static final int stopButton=0x7f060006;
public static final int timeInSeconds=0x7f060002;
}
public static final class layout {
public static final int digital_clock=0x7f030000;
public static final int main=0x7f030001;
}
public static final class raw {
public static final int one_obe_radio_one=0x7f040000;
public static final int one_obe_radio_one_old=0x7f040001;
}
public static final class string {
public static final int app_name=0x7f050001;
public static final int hello=0x7f050000;
}
}
Binary file added Projects/Chapter11/res/drawable/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projects/Chapter11/res/drawable/image1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit feec376

Please sign in to comment.