[android-developers] Re: ReStarting An Activity From A Service

2009-04-21 Thread Mohamed Amir

Yes, I have set the activity android:launchMode=singleTop in the
manifest, but still in vain.

I have put breakpoints in onCreate() and onNewIntent().
onCreate is called only the first time, and onNewIntent is never
called.



On Apr 21, 12:37 am, Dianne Hackborn hack...@android.com wrote:
 Did you try setting android:launchMode=singleTop in your manifest?

 On Mon, Apr 20, 2009 at 3:11 PM, Mohamed Amir mohamed.a...@gmail.comwrote:





  :-)
  Well, it's just a typo here but it is correct in the code I have
  tried.

  Thank you after all.

  On Apr 20, 10:14 pm, Marco Nelissen marc...@android.com wrote:
   On Mon, Apr 20, 2009 at 12:15 PM, Mohamed Amir mohamed.a...@gmail.com
  wrote:

OK Mark.

I am trying to make an application that show the caller-ID when there
is an incoming call.
And where there is another call, I wanna update the caller-ID shown.

I have tried OnNewIntent but this callback wasn't called.

   It's onNewIntent() with a lowercase 'o'.

 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-21 Thread Mohamed Amir

Hi Dianne,

I have found this in the doc.

 when the activity is re-launched while at the top of the activity
stack instead of a new instance of the activity being started,
onNewIntent() will be called on the existing instance with the Intent
that was used to re-launch it.

on my case, the incoming call dialog is shown and hence I think the
activity isn't at the top of activity stack, you think this might be
the reason?


Is there a way that I close the activity and re-launch it from inside
the service?



On Apr 21, 2:22 pm, Mohamed Amir mohamed.a...@gmail.com wrote:
 Yes, I have set the activity android:launchMode=singleTop in the
 manifest, but still in vain.

 I have put breakpoints in onCreate() and onNewIntent().
 onCreate is called only the first time, and onNewIntent is never
 called.

 On Apr 21, 12:37 am, Dianne Hackborn hack...@android.com wrote:

  Did you try setting android:launchMode=singleTop in your manifest?

  On Mon, Apr 20, 2009 at 3:11 PM, Mohamed Amir mohamed.a...@gmail.comwrote:

   :-)
   Well, it's just a typo here but it is correct in the code I have
   tried.

   Thank you after all.

   On Apr 20, 10:14 pm, Marco Nelissen marc...@android.com wrote:
On Mon, Apr 20, 2009 at 12:15 PM, Mohamed Amir mohamed.a...@gmail.com
   wrote:

 OK Mark.

 I am trying to make an application that show the caller-ID when there
 is an incoming call.
 And where there is another call, I wanna update the caller-ID shown.

 I have tried OnNewIntent but this callback wasn't called.

It's onNewIntent() with a lowercase 'o'.

  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com

  Note: please don't send private questions to me, as I don't have time to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see and
  answer them.
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-21 Thread Mohamed Amir

OK, sorry, Dianne.
It works now.  I just did as you said, I am not sure why it wasn't
working in the first place.

Thank you Dianne.


On Apr 21, 2:50 pm, Mohamed Amir mohamed.a...@gmail.com wrote:
 Hi Dianne,

 I have found this in the doc.

  when the activity is re-launched while at the top of the activity
 stack instead of a new instance of the activity being started,
 onNewIntent() will be called on the existing instance with the Intent
 that was used to re-launch it.

 on my case, the incoming call dialog is shown and hence I think the
 activity isn't at the top of activity stack, you think this might be
 the reason?

 Is there a way that I close the activity and re-launch it from inside
 the service?

 On Apr 21, 2:22 pm, Mohamed Amir mohamed.a...@gmail.com wrote:

  Yes, I have set the activity android:launchMode=singleTop in the
  manifest, but still in vain.

  I have put breakpoints in onCreate() and onNewIntent().
  onCreate is called only the first time, and onNewIntent is never
  called.

  On Apr 21, 12:37 am, Dianne Hackborn hack...@android.com wrote:

   Did you try setting android:launchMode=singleTop in your manifest?

   On Mon, Apr 20, 2009 at 3:11 PM, Mohamed Amir 
   mohamed.a...@gmail.comwrote:

:-)
Well, it's just a typo here but it is correct in the code I have
tried.

Thank you after all.

On Apr 20, 10:14 pm, Marco Nelissen marc...@android.com wrote:
 On Mon, Apr 20, 2009 at 12:15 PM, Mohamed Amir mohamed.a...@gmail.com
wrote:

  OK Mark.

  I am trying to make an application that show the caller-ID when 
  there
  is an incoming call.
  And where there is another call, I wanna update the caller-ID shown.

  I have tried OnNewIntent but this callback wasn't called.

 It's onNewIntent() with a lowercase 'o'.

   --
   Dianne Hackborn
   Android framework engineer
   hack...@android.com

   Note: please don't send private questions to me, as I don't have time to
   provide private support, and so won't reply to such e-mails.  All such
   questions should be posted on public forums, where I and others can see 
   and
   answer them.
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-21 Thread Mohamed Amir

I am sorry, but the same code doesn't run now.
I am testing on the emulator.  Can it be a timing issue?  if the
service is invoked before the incoming call dialog captures the focus,
it works because the activity is then on top of stack?



On Apr 21, 2:57 pm, Mohamed Amir mohamed.a...@gmail.com wrote:
 OK, sorry, Dianne.
 It works now.  I just did as you said, I am not sure why it wasn't
 working in the first place.

 Thank you Dianne.

 On Apr 21, 2:50 pm, Mohamed Amir mohamed.a...@gmail.com wrote:

  Hi Dianne,

  I have found this in the doc.

   when the activity is re-launched while at the top of the activity
  stack instead of a new instance of the activity being started,
  onNewIntent() will be called on the existing instance with the Intent
  that was used to re-launch it.

  on my case, the incoming call dialog is shown and hence I think the
  activity isn't at the top of activity stack, you think this might be
  the reason?

  Is there a way that I close the activity and re-launch it from inside
  the service?

  On Apr 21, 2:22 pm, Mohamed Amir mohamed.a...@gmail.com wrote:

   Yes, I have set the activity android:launchMode=singleTop in the
   manifest, but still in vain.

   I have put breakpoints in onCreate() and onNewIntent().
   onCreate is called only the first time, and onNewIntent is never
   called.

   On Apr 21, 12:37 am, Dianne Hackborn hack...@android.com wrote:

Did you try setting android:launchMode=singleTop in your manifest?

On Mon, Apr 20, 2009 at 3:11 PM, Mohamed Amir 
mohamed.a...@gmail.comwrote:

 :-)
 Well, it's just a typo here but it is correct in the code I have
 tried.

 Thank you after all.

 On Apr 20, 10:14 pm, Marco Nelissen marc...@android.com wrote:
  On Mon, Apr 20, 2009 at 12:15 PM, Mohamed Amir 
  mohamed.a...@gmail.com
 wrote:

   OK Mark.

   I am trying to make an application that show the caller-ID when 
   there
   is an incoming call.
   And where there is another call, I wanna update the caller-ID 
   shown.

   I have tried OnNewIntent but this callback wasn't called.

  It's onNewIntent() with a lowercase 'o'.

--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see 
and
answer them.
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-20 Thread Mohamed Amir

OK Mark.

I am trying to make an application that show the caller-ID when there
is an incoming call.
And where there is another call, I wanna update the caller-ID shown.

I have tried OnNewIntent but this callback wasn't called.

The service code is something like that

@Override
public void onStart(Intent intent, int startId) {
phoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, 
String incomingNumber) {
super.onCallStateChanged(state, 
incomingNumber);
switch (state) {
case 
TelephonyManager.CALL_STATE_RINGING:

Intent intent = new Intent();

intent.setClass(getApplicationContext(),

IncomingCallActivity.class);

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(phoneNumber, 
incomingNumber);
startActivity(intent);

break;
}
}

};

}

Is there something I'm missing?

Thank you.

On Apr 19, 8:04 pm, Mark Murphy mmur...@commonsware.com wrote:
 Mohamed Amir wrote:
  Mark: The user isn't supposed to be doing anything.  Just reading some
  information, and it's required to see the most updated information
  sent by the service.

 What if they are in the middle of writing a text message, or are using
 some other application? Why do you think you have the right to intrude
 upon their use of their device this way?

 If you are taking some steps to ensure that the only time you start an
 activity from your service is if one of your other activities is in the
 foreground...then that is your call. I think ensuring that behavior will
 be difficult to get right 100% of the time.

 Otherwise, I have not yet seen a valid use case of a service launching
 an activity. If anyone has such a use case, chime in, and let us know
 how you are not irritating your users!

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Warescription: Three Android Books, Plus Updates, $35/Year
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-20 Thread Jonas Petersson

Hi Mohamed,

Mohamed Amir wrote:
 I am trying to make an application that show the caller-ID when there
 is an incoming call.
 And where there is another call, I wanna update the caller-ID shown.

Sounds familiar - I do similar stuff in Zap's Hitta (see Market).

 I have tried OnNewIntent but this callback wasn't called.
 
 The service code is something like that
 [...]
 Is there something I'm missing?

Probably this permission in your manifest:

android.permission.READ_PHONE_STATE

Good luck / Jonas

--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-20 Thread Mohamed Amir

Hi Jonas,

Thank you for your reply.

The activity is created properly when an incoming call takes place.
The problem is when another call takes place and the first activity is
still shown.

I think it's not a permission problem.

On Apr 20, 9:30 pm, Jonas Petersson jonas.peters...@xms.se wrote:
 Hi Mohamed,

 Mohamed Amir wrote:
  I am trying to make an application that show the caller-ID when there
  is an incoming call.
  And where there is another call, I wanna update the caller-ID shown.

 Sounds familiar - I do similar stuff in Zap's Hitta (see Market).

  I have tried OnNewIntent but this callback wasn't called.

  The service code is something like that
  [...]
  Is there something I'm missing?

 Probably this permission in your manifest:

 android.permission.READ_PHONE_STATE

                 Good luck / Jonas
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-20 Thread Marco Nelissen
On Mon, Apr 20, 2009 at 12:15 PM, Mohamed Amir mohamed.a...@gmail.comwrote:


 OK Mark.

 I am trying to make an application that show the caller-ID when there
 is an incoming call.
 And where there is another call, I wanna update the caller-ID shown.

 I have tried OnNewIntent but this callback wasn't called.


It's onNewIntent() with a lowercase 'o'.

--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-20 Thread Mohamed Amir

:-)
Well, it's just a typo here but it is correct in the code I have
tried.

Thank you after all.


On Apr 20, 10:14 pm, Marco Nelissen marc...@android.com wrote:
 On Mon, Apr 20, 2009 at 12:15 PM, Mohamed Amir mohamed.a...@gmail.comwrote:



  OK Mark.

  I am trying to make an application that show the caller-ID when there
  is an incoming call.
  And where there is another call, I wanna update the caller-ID shown.

  I have tried OnNewIntent but this callback wasn't called.

 It's onNewIntent() with a lowercase 'o'.
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-20 Thread Dianne Hackborn
Did you try setting android:launchMode=singleTop in your manifest?

On Mon, Apr 20, 2009 at 3:11 PM, Mohamed Amir mohamed.a...@gmail.comwrote:


 :-)
 Well, it's just a typo here but it is correct in the code I have
 tried.

 Thank you after all.


 On Apr 20, 10:14 pm, Marco Nelissen marc...@android.com wrote:
  On Mon, Apr 20, 2009 at 12:15 PM, Mohamed Amir mohamed.a...@gmail.com
 wrote:
 
 
 
   OK Mark.
 
   I am trying to make an application that show the caller-ID when there
   is an incoming call.
   And where there is another call, I wanna update the caller-ID shown.
 
   I have tried OnNewIntent but this callback wasn't called.
 
  It's onNewIntent() with a lowercase 'o'.
 



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-19 Thread Mohamed Amir

Thank you for your answers.

Marco: I will check your solution.

Mark: The user isn't supposed to be doing anything.  Just reading some
information, and it's required to see the most updated information
sent by the service.



On Apr 18, 5:56 pm, Mark Murphy mmur...@commonsware.com wrote:
  I have a Service that starts an Activity on certain event passing to
  it some parameters.

 I do not recommend this. What if the user is in the middle of doing
 something else?

  The problem is if the Activity is still open, when the service tries
  to startActivity() again, the activity isn't started because it's
  already started.

 http://developer.android.com/guide/topics/fundamentals.html#lmodeshttp://developer.android.com/guide/topics/fundamentals.html#clearstack

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-19 Thread Mark Murphy

Mohamed Amir wrote:
 Mark: The user isn't supposed to be doing anything.  Just reading some
 information, and it's required to see the most updated information
 sent by the service.

What if they are in the middle of writing a text message, or are using
some other application? Why do you think you have the right to intrude
upon their use of their device this way?

If you are taking some steps to ensure that the only time you start an
activity from your service is if one of your other activities is in the
foreground...then that is your call. I think ensuring that behavior will
be difficult to get right 100% of the time.

Otherwise, I have not yet seen a valid use case of a service launching
an activity. If anyone has such a use case, chime in, and let us know
how you are not irritating your users!

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, $35/Year

--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: ReStarting An Activity From A Service

2009-04-18 Thread Mark Murphy

 I have a Service that starts an Activity on certain event passing to
 it some parameters.

I do not recommend this. What if the user is in the middle of doing
something else?

 The problem is if the Activity is still open, when the service tries
 to startActivity() again, the activity isn't started because it's
 already started.

http://developer.android.com/guide/topics/fundamentals.html#lmodes
http://developer.android.com/guide/topics/fundamentals.html#clearstack

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~-~--~~~---~--~~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---