thank you for your reply - as i said, the code worked fine in the main activity, sendmail.java, but when i moved it to GetContacts.java i get a nullPrtException from EmailContactsRepeat where the call is. i am also listing the intent reciever where the code is called.
here is the manifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.apache.android.mail"> <uses-permission android:name="android.permission.READ_CONTACTS"/> <application> <receiver android:name=".EmailContactsRepeat" android:process=":remote" /> <activity android:name=".SendMail" android:label="SendMail"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".SendContacts" > </activity> <activity android:name=".GetContacts" > </activity> </application> </manifest> here is the intent package org.apache.android.mail; import android.content.Context; import android.content.Intent; import android.content.IntentReceiver; public class EmailContactsRepeat extends IntentReceiver { @Override public void onReceiveIntent(Context context, Intent intent) { //get bundle of extras (userid, passwork, email) from intent String userid = intent.getStringExtra("userid"); String password = intent.getStringExtra("password"); String email = intent.getStringExtra("email"); int foo=0; int rbutton = intent.getIntExtra("rbutton", foo); //String body = "test"; //final String body = getContactStr(); GetContacts g= new GetContacts(); String body = g.getContactStr(); body += body + rbutton; SendContacts s = new SendContacts (body,userid, password, email,rbutton); } } here is GetContacts.java package org.apache.android.mail; import android.app.Activity; import android.database.Cursor; public class GetContacts extends Activity { public String getContactStr() { String pList = ""; String st = ""; Cursor c = getContentResolver().query( android.provider.Contacts.Phones.CONTENT_URI, null, null, null, android.provider.Contacts.Phones.PERSON_ID+ " ASC"); startManagingCursor(c); // Retrieve the column-indixes of phoneNumber, name and type int numberColumn = c.getColumnIndex(android.provider.Contacts.Phones.NUMBER); int nameColumn = c.getColumnIndex(android.provider.Contacts.Phones.NAME); // type can be: home, cell, etc (number provided - must be interpreted int typeColumn = c.getColumnIndex(android.provider.Contacts.Phones.TYPE); int labelColumn = c.getColumnIndex(android.provider.Contacts.Phones.LABEL); // Will hold the calls, available to the cursor // Loop through all entries the cursor provides to us. if(c.first()){ do{ String callerPhoneNumber = c.getString(numberColumn); String pname = c.getString(nameColumn); int pType = c.getInt(typeColumn); String label = c.getString(labelColumn); if (label != null) st = label; else st = getPhoneType(pType); pList = pList + "\n# " + callerPhoneNumber +" " + pname +" " + st; }while(c.next()); } if (pList == "") return ("No Contacts in Phone # blah"); else return pList; } private String getPhoneType(int p) { String st = ""; switch(p) { case android.provider.Contacts.Phones.HOME_TYPE: st = "Home"; break; case android.provider.Contacts.Phones.HOME_FAX_TYPE: st = "HomeFax"; break; case android.provider.Contacts.Phones.MOBILE_TYPE: st = "Cell"; break; case android.provider.Contacts.Phones.WORK_TYPE: st = "Work"; break; case android.provider.Contacts.Phones.OTHER_TYPE: st = ""; break; case android.provider.Contacts.Phones.WORK_FAX_TYPE: st = "WorkFax"; break; case android.provider.Contacts.Phones.PAGER_TYPE: st = "Pager"; break; } return st; } } here is the main activity, i commented out the code, but it worked fine when called from here. package org.apache.android.mail; import android.app.Activity; import android.app.AlarmManager; import android.content.Intent; import android.os.Bundle; import android.os.SystemClock; import android.view.View; import android.view.View.OnClickListener; import android.widget.EditText; import android.widget.RadioGroup; import android.widget.Button; import android.widget.Toast; public class SendMail extends Activity implements RadioGroup.OnCheckedChangeListener{ /** * Called with the activity is first created. */ private RadioGroup mRadioGroup; private int rbutton; Toast mToast; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); final Button send = (Button) this.findViewById(R.id.send); final Button cancel = (Button) this.findViewById(R.id.cancel); final EditText userid = (EditText) this.findViewById(R.id.userid); final EditText password = (EditText) this.findViewById(R.id.password); final EditText from = (EditText) this.findViewById(R.id.from); cancel.setOnClickListener(mStopRepeatingListener); //final String body = getContactStr(); //final String subject = "Contacts from phone"; send.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { //final String body = getContactStr(); String body = "test"; Intent intent = new Intent(SendMail.this, EmailContactsRepeat.class); // bundle extras (data) with the intent. intent.putExtra("userid", userid.getText().toString()); intent.putExtra("password", password.getText().toString()); intent.putExtra("email", from.getText().toString()); intent.putExtra("rbutton", rbutton); // We want the alarm to go off now. long firstTime = SystemClock.elapsedRealtime(); // Schedule the alarm! AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE); am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, 60*1000, intent); } }); } public void onCheckedChanged(RadioGroup group, int checkedId) { //String selection = getString(R.string.radio_group_selection); //String none = getString(R.string.radio_group_none); //mChoice.setText(selection + // (checkedId == View.NO_ID ? none : checkedId)); rbutton = checkedId; if (checkedId == R.id.everyday) rbutton = 1; else if (checkedId == R.id.days2) rbutton = 2; else rbutton = 3; } private OnClickListener mStopRepeatingListener = new OnClickListener() { public void onClick(View v) { // Create the same intent that was scheduled. Intent intent = new Intent(SendMail.this, EmailContactsRepeat.class); // And cancel the alarm. AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE); am.cancel(intent); // Tell the user about what we did. if (mToast != null) { mToast.cancel(); } mToast = Toast.makeText(SendMail.this, R.string.cancel_contacts, Toast.LENGTH_LONG); mToast.show(); } }; /* private String getContactStr() { String pList = ""; String st = ""; Cursor c = getContentResolver().query( android.provider.Contacts.Phones.CONTENT_URI, null, null, null, android.provider.Contacts.Phones.PERSON_ID+ " ASC"); startManagingCursor(c); // Retrieve the column-indixes of phoneNumber, name and type int numberColumn = c.getColumnIndex(android.provider.Contacts.Phones.NUMBER); int nameColumn = c.getColumnIndex(android.provider.Contacts.Phones.NAME); // type can be: home, cell, etc (number provided - must be interpreted int typeColumn = c.getColumnIndex(android.provider.Contacts.Phones.TYPE); int labelColumn = c.getColumnIndex(android.provider.Contacts.Phones.LABEL); // Will hold the calls, available to the cursor // Loop through all entries the cursor provides to us. if(c.first()){ do{ String callerPhoneNumber = c.getString(numberColumn); String pname = c.getString(nameColumn); int pType = c.getInt(typeColumn); String label = c.getString(labelColumn); if (label != null) st = label; else st = getPhoneType(pType); pList = pList + "\n# " + callerPhoneNumber +" " + pname +" " + st; }while(c.next()); } if (pList == "") return ("No Contacts in Phone # blah"); else return pList; } private String getPhoneType(int p) { String st = ""; switch(p) { case android.provider.Contacts.Phones.HOME_TYPE: st = "Home"; break; case android.provider.Contacts.Phones.HOME_FAX_TYPE: st = "HomeFax"; break; case android.provider.Contacts.Phones.MOBILE_TYPE: st = "Cell"; break; case android.provider.Contacts.Phones.WORK_TYPE: st = "Work"; break; case android.provider.Contacts.Phones.OTHER_TYPE: st = ""; break; case android.provider.Contacts.Phones.WORK_FAX_TYPE: st = "WorkFax"; break; case android.provider.Contacts.Phones.PAGER_TYPE: st = "Pager"; break; } return st; } */ } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---