0

I'm try to implement a call log in my Android app, which reads the system call log and shows on my app. There's a button to make a call to someone in my app with the code of:

startActivity(new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+dataList.get(arg2).get("number"))));  

When I press the button, my app will lose focus of the screen and it will jump to the calling page. When the call finishes, I want the call log in my app could be refreshed, I mean, the call just now should be added to my list. So I add refreshing functions in the onResume() of my Activity.

But it weirdly turned out the list didn't refresh when the call finishes(the screen automatically turns back to my previous page of my app, say the list).

So here comes my question, shouldn't be the onResume() function be called when the call finishes? Meanwhile, the onPause() wasn't called either, when jumping to the calling page. I'm pretty sure they weren't called cuz I add system.out.println() at the beginning of onResume() and onPause(), and I saw nothing.

Could anyone here help me with this problem? Thanks for all your read and help.

Yuchun Cui
  • 69
  • 2
  • 7
  • Are you sure you are checking the correct part of the logcat for the print messages? [See this answer](http://stackoverflow.com/questions/2220547/why-doesnt-system-out-println-work-in-android) if you are unsure. I prefer breakpoints most of the time to see exactly where/when my code is being called. – codeMagic Oct 13 '13 at 02:29
  • Hey dude thanks for your help actually I was looking at the right logcat. Mike helped me below. Anyway, thanks for answering! – Yuchun Cui Oct 13 '13 at 04:57

1 Answers1

1

Make sure you correctly override the onPause() and onResume() methods. (no parameters, void return type)

You will also need to call through to the super method in each case, too. That is:

@Override
public void onPause()
{
    super.onPause();
    // your code here
}

@Override
public void onResume()
{
    super.onResume();
    // your code here
}
Mike M.
  • 38,532
  • 8
  • 99
  • 95
  • Thanks Mike that's so careless a mistake. But could you please help me with this further question: I just found the onResume() will be called although you start the app for the first time. Is that correct? Thanks! – Yuchun Cui Oct 13 '13 at 04:56
  • @YuchunCui that is correct. Look at the [Activity Lifecycle](http://developer.android.com/reference/android/app/Activity.html). `onResume()` is called directly after `onCreate()` the first time the `Activity` is created. – codeMagic Oct 13 '13 at 04:59