how to open contacts application

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

how to open contacts application

Postby mancoeg » Tue Mar 10, 2009 3:35 pm

hi every body

i 've already got the android source code
and i tried to open the contacts application which i found in the android source code using ecliipse
but alot of errors appear when i do this
any help
mancoeg
Freshman
Freshman
 
Posts: 2
Joined: Sun Mar 08, 2009 8:06 pm

Top

Postby umair » Tue Mar 17, 2009 6:03 am

this activity would work perfectly. You won't need to change anything in this code except the package name.
Don't forget to add following prmission in your AndroidManifest.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.READ_CONTACTS" />
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package com.***;;
  3.  
  4.  
  5.  
  6. import android.app.AlertDialog;
  7.  
  8. import android.app.ExpandableListActivity;
  9.  
  10. import android.content.ContentUris;
  11.  
  12. import android.content.Context;
  13.  
  14. import android.database.Cursor;
  15.  
  16. import android.net.Uri;
  17.  
  18. import android.os.Bundle;
  19.  
  20. import android.provider.Contacts.People;
  21.  
  22. import android.view.View;
  23.  
  24. import android.view.View.OnClickListener;
  25.  
  26. import android.widget.ExpandableListAdapter;
  27.  
  28. import android.widget.SimpleCursorTreeAdapter;
  29.  
  30.  
  31.  
  32.  
  33.  
  34. /**
  35.  
  36.  * Demonstrates expandable lists backed by Cursors
  37.  
  38.  */
  39.  
  40. public class ShowContacts extends ExpandableListActivity implements OnClickListener {
  41.  
  42.     private int mGroupIdColumnIndex;
  43.  
  44.    
  45.  
  46.     private String mPhoneNumberProjection[] = new String[] {
  47.  
  48.             People.Phones._ID, People.Phones.NUMBER
  49.  
  50.     };
  51.  
  52.  
  53.  
  54.    
  55.  
  56.     private ExpandableListAdapter mAdapter;
  57.  
  58.    
  59.  
  60.  
  61.  
  62.     @Override
  63.  
  64.     public void onCreate(Bundle savedInstanceState) {
  65.  
  66.         super.onCreate(savedInstanceState);
  67.  
  68.  
  69.  
  70.         // Query for people
  71.  
  72.         Cursor groupCursor = managedQuery(People.CONTENT_URI,
  73.  
  74.                 new String[] {People._ID, People.NAME}, null, null, null);
  75.  
  76.  
  77.  
  78.         // Cache the ID column index
  79.  
  80.         mGroupIdColumnIndex = groupCursor.getColumnIndexOrThrow(People._ID);
  81.  
  82.  
  83.  
  84.         // Set up our adapter
  85.  
  86.         mAdapter = new MyExpandableListAdapter(groupCursor,
  87.  
  88.                 this,
  89.  
  90.                 android.R.layout.simple_expandable_list_item_1,
  91.  
  92.                 android.R.layout.simple_expandable_list_item_1,
  93.  
  94.                 new String[] {People.NAME}, // Name for group layouts
  95.  
  96.                 new int[] {android.R.id.text1},
  97.  
  98.                 new String[] {People.NUMBER}, // Number for child layouts
  99.  
  100.                 new int[] {android.R.id.text1});
  101.  
  102.         setListAdapter(mAdapter);
  103.  
  104.     }
  105.  
  106.    
  107.  
  108.     @Override
  109.  
  110.         public void onClick(View v) {
  111.  
  112.                 AlertDialog dialog = new AlertDialog.Builder(ShowContacts.this)
  113.  
  114.         .setTitle("UmaiR")
  115.  
  116.         .setMessage(v.getId())
  117.  
  118.         .create();
  119.  
  120.                 dialog.show();
  121.  
  122.         }
  123.  
  124.  
  125.  
  126.     public class MyExpandableListAdapter extends SimpleCursorTreeAdapter {
  127.  
  128.  
  129.  
  130.         public MyExpandableListAdapter(Cursor cursor, Context context, int groupLayout,
  131.  
  132.                 int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom,
  133.  
  134.                 int[] childrenTo) {
  135.  
  136.             super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childrenFrom,
  137.  
  138.                     childrenTo);
  139.  
  140.         }
  141.  
  142.  
  143.  
  144.         @Override
  145.  
  146.         protected Cursor getChildrenCursor(Cursor groupCursor) {
  147.  
  148.             // Given the group, we return a cursor for all the children within that group
  149.  
  150.  
  151.  
  152.             // Return a cursor that points to this contact's phone numbers
  153.  
  154.             Uri.Builder builder = People.CONTENT_URI.buildUpon();
  155.  
  156.             ContentUris.appendId(builder, groupCursor.getLong(mGroupIdColumnIndex));
  157.  
  158.             builder.appendEncodedPath(People.Phones.CONTENT_DIRECTORY);
  159.  
  160.             Uri phoneNumbersUri = builder.build();
  161.  
  162.  
  163.  
  164.             // The returned Cursor MUST be managed by us, so we use Activity's helper
  165.  
  166.             // functionality to manage it for us.
  167.  
  168.             return managedQuery(phoneNumbersUri, mPhoneNumberProjection, null, null, null);
  169.  
  170.         }
  171.  
  172.     }
  173.  
  174. }
  175.  
  176.  
  177.  
  178.  
Parsed in 0.043 seconds, using GeSHi 1.0.8.4
Muhammad Umair
User avatar
umair
Developer
Developer
 
Posts: 28
Joined: Thu Feb 26, 2009 1:00 pm
Location: Lahore, Pakistan

hi

Postby mancoeg » Thu Mar 19, 2009 11:31 am

thanks for you reply

but it did not work with me

by the way i notice that all poeple on internet are talking about 2 Giga for the size of android source
but what i've beeni downloaded id only 1 Giga

so i'm confused

i'm working on ubuntu as an operating system

would you please send me a right ling to download the full android source code
and would you please send me the contacts application after making the reqiured changes

my mail is "mancoeg@yahoo.com"

thanks
mancoeg
Freshman
Freshman
 
Posts: 2
Joined: Sun Mar 08, 2009 8:06 pm

Postby kali » Sat May 02, 2009 11:44 am

hai umair
Is it possible to open alarmclock application same as you apply for contact
if possible send some code or links.
thanks in advanse
kali
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Tue Jan 27, 2009 1:31 pm

Postby kali » Thu May 07, 2009 7:12 am

hai umar
this application works fine with me.
but is it possible to open default contact application from any running application?
if possible please tell me that way?\
kali
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Tue Jan 27, 2009 1:31 pm

Postby umair » Wed Jul 08, 2009 4:36 am

For both of your queries, the problem is one, i.e., you want to open another app from your app.

It's not very tough. You'll find some articles in this forum as well. Just try a search :)
Muhammad Umair
User avatar
umair
Developer
Developer
 
Posts: 28
Joined: Thu Feb 26, 2009 1:00 pm
Location: Lahore, Pakistan

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google Feedfetcher, Majestic-12 [Bot] and 5 guests