BroadcastReceiver and onRestart

by RyJan » Sat, 07 Mar 2009 10:53:19 GMT


Sponsored Links
 I have an app that has an integrated BroadcastReceiver to handle
incoming calls.  That BCR interacts with the NotificationManager to
post text to the notification bar on the top of the screen.

In previous versions it seemed that when the user would use the
Notification drag-down to get into my App, the onCreate method would
be called essentially re-initializing my app.

In 1.1 this doesn't seem to happen, i need to manually refresh my app
to list new data.

I was curious if its was ok to override the OnRestart() method in my
activity to refresh my data list?

or is there a better way to let my activity know through the
BroadcastReceiver that it needs to look for new data?

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. attempting to insert a contact

I've looked at the other code fragments in this forum, and at the
sample code in the "Accessing Content Providers" document, but I'm
still having problems.  The following code fragment dies with an
IOException at
     uri = getContentResolver().insert(Contacts.People.CONTENT_URI,
contact);

Can someone please point out where I am going astray?

Thanks, Robert O'Hara

----------------------

import android.app.Activity;
import android.content.ContentValues;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Contacts;
import android.provider.Contacts.Phones;
import android.view.KeyEvent;

public class Testbed extends Activity {
//
*************************************************************************************************
// Testbed is used to try out new program fragments.
//
*************************************************************************************************

public void onCreate(Bundle savedInstanceState) {
//
-------------------------------------------------------------------------------------------------
// Create our activity.
//
-------------------------------------------------------------------------------------------------
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

InsertContact("Harry Ijen", "+18142386651", 1);
}

public void InsertContact(String name, String phoneNumber, int
favorite) {
//
-------------------------------------------------------------------------------------------------
// Insert a new contact into the contacts application.
//
-------------------------------------------------------------------------------------------------
Uri phoneUri = null;
Uri uri = null;

ContentValues contact = new ContentValues();
contact.put(Contacts.People.NAME, name);
contact.put(Contacts.People.STARRED, favorite);
uri = getContentResolver().insert(Contacts.People.CONTENT_URI,
contact);

// Now get the CONTENT_URI of the contact we just inserted & build the
URI for the phone num.
phoneUri = Uri.withAppendedPath(uri,
Contacts.People.Phones.CONTENT_DIRECTORY);
contact.clear();
contact.put(Contacts.Phones.TYPE, Phones.TYPE_MOBILE);
contact.put(Contacts.Phones.NUMBER, phoneNumber);
getContentResolver().insert(phoneUri, contact);
}

public boolean onKeyUp(int keyCode, KeyEvent keyMsg) {
//
-------------------------------------------------------------------------------------------------
// Terminate the application if the user presses the Q key.
//
-------------------------------------------------------------------------------------------------
if (keyCode == KeyEvent.KEYCODE_Q) finish();
return true;
}

}

--~--~---------~--~----~------------~-------~--~----~

2. Design decision on Local Service versus Remote Service

I understand that local service runs in the same process as the app
and remote service runs in a separate process as the app.  Also,
Remote service requires IPC to communicate with client.  But can
someone give me concrete examples of when local service service should
be used (and remote service)?
--~--~---------~--~----~------------~-------~--~----~

3. first Map app getting "stopped unexpectedly" error - how to get more info?

4. intent for sent message

5. Listview click event with button

6. keytool usage different, can't generate debug MD5 fingerprint - resolved

7. eclipse debug keystore and google maps api key problem