[android-developers] Re: Broadcast receiver receive empty extras

2012-04-19 Thread viktor
I copy My trouble from another thread:

I had a simple app that has Service and Application.
Application starts Service by Action with Intent.

The Service received Intent with onStartCommand and handle some action
by
key that is in Intent.

Sometime Service receives empty Intent.

public void sendRequest(int type, Intent data) {
  Intent i = new Intent(getLocalServiceAction());
  i =
i.putExtras(data).putExtra(LocalApiService.INTENT_NAME_REQUEST_ID,
type);
  startService(i);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
  if (intent != null) {
onHandleIntent(intent);
  }
  return START_REDELIVER_INTENT;
}

protected void onHandleIntent(Intent intent) {
  prepareDataFromReceiver(intent);
}
public void prepareDataFromReceiver(Intent extras) {
  int type =
extras.getIntExtra(LocalApiService.INTENT_NAME_REQUEST_ID, -1);
  //Sometime type doesn't in Intent
  ...
}


I have fixed my problem with service manifest
parameter( android:process=":MyService");


On 19 Кві, 14:18, TreKing  wrote:
> On Thu, Apr 19, 2012 at 3:04 AM, viktor  wrote:
> > Didn't fix my problem, after a long time I still receive an empty Extras,
> > it is on 2.1.
>
> You need to explain your problem better. Like what is "a long time". What
> is different between these times?
>
> --- 
> --
> TreKing  - Chicago
> transit tracking app for Android-powered devices

-- 
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


Re: [android-developers] Re: Broadcast receiver receive empty extras

2012-04-19 Thread TreKing
On Thu, Apr 19, 2012 at 3:04 AM, viktor  wrote:

> Didn't fix my problem, after a long time I still receive an empty Extras,
> it is on 2.1.
>

You need to explain your problem better. Like what is "a long time". What
is different between these times?

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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: Broadcast receiver receive empty extras

2012-04-19 Thread viktor
Didn't fix my problem, after a long time I still receive an empty
Extras, it is on 2.1.

On 18 Кві, 22:00, TreKing  wrote:
> On Wed, Apr 18, 2012 at 1:51 PM, viktor  wrote:
> > Yes, I agree with but sometimes an Extras comes with Bundle[{}];
>
> I don't know what that means.
>
> > You also can take a look to this thread:
> >http://groups.google.com/group/android-developers/browse_thread/threa...
>
> Your link is bad.
>
> --- 
> --
> TreKing  - Chicago
> transit tracking app for Android-powered devices

-- 
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


Re: [android-developers] Re: Broadcast receiver receive empty extras

2012-04-18 Thread TreKing
On Wed, Apr 18, 2012 at 1:51 PM, viktor  wrote:

> Yes, I agree with but sometimes an Extras comes with Bundle[{}];
>

I don't know what that means.


> You also can take a look to this thread:
> http://groups.google.com/group/android-developers/browse_thread/threa...
>

Your link is bad.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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

Re: [android-developers] Re: Broadcast receiver receive empty extras

2012-04-18 Thread Justin Anderson
>
> Originally, you were putting the int in the bundle, then the bundle in the
> intent. On receipt, you were trying to get the data from the intent.

Wow... can't believe I missed that.  Woops!

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Wed, Apr 18, 2012 at 12:36 PM, TreKing  wrote:

> Originally, you were putting the int in the bundle, then the bundle in the
> intent. On receipt, you were trying to get the data from the intent.
>

-- 
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: Broadcast receiver receive empty extras

2012-04-18 Thread viktor
Yes, I agree with but sometimes an Extras comes with Bundle[{}];

You also can take a look to this thread:
http://groups.google.com/group/android-developers/browse_thread/threa...


On 18 Кві, 21:36, TreKing  wrote:
> On Wed, Apr 18, 2012 at 1:24 PM, viktor  wrote:
> > Seems works with i.putExtra(LocalApiService.INTENT_EXTRA, data),
> > thanks.
>
> > What is the problem was?
>
> Originally, you were putting the int in the bundle, then the bundle in the
> intent. On receipt, you were trying to get the data from the intent.
>
> It would probably also work if you did i.getExtras().getInt(...).
>
> --- 
> --
> TreKing  - Chicago
> transit tracking app for Android-powered devices

-- 
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


Re: [android-developers] Re: Broadcast receiver receive empty extras

2012-04-18 Thread TreKing
On Wed, Apr 18, 2012 at 1:24 PM, viktor  wrote:

> Seems works with i.putExtra(LocalApiService.INTENT_EXTRA, data),
> thanks.
>
> What is the problem was?
>

Originally, you were putting the int in the bundle, then the bundle in the
intent. On receipt, you were trying to get the data from the intent.

It would probably also work if you did i.getExtras().getInt(...).

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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: Broadcast receiver receive empty extras

2012-04-18 Thread viktor
Seems works with i.putExtra(LocalApiService.INTENT_EXTRA, data),
thanks.

What is the problem was?

On 18 Кві, 20:03, Justin Anderson  wrote:
> I don't really see anything wrong there...  Have you tried this 
> method?http://developer.android.com/reference/android/content/Intent.html#pu...
>
> Thanks,
> Justin Anderson
> MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
>
>
>
>
>
>
> On Wed, Apr 18, 2012 at 10:49 AM, viktor  wrote:
> > startId

-- 
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


Re: [android-developers] Re: Broadcast receiver receive empty extras

2012-04-18 Thread Justin Anderson
I don't really see anything wrong there...  Have you tried this method?
http://developer.android.com/reference/android/content/Intent.html#putExtra%28java.lang.String,%20android.os.Bundle%29

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Wed, Apr 18, 2012 at 10:49 AM, viktor  wrote:

> startId

-- 
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: Broadcast receiver receive empty extras

2012-04-18 Thread viktor
Application:

public void sendRequest(int type, Bundle data) {
Intent i = new Intent(getLocalServiceAction());
data.putInt(LocalApiService.INTENT_NAME_REQUEST_ID, type);
i.putExtras(data);
ALLogger.log(Log.DEBUG, TAG, "sendRequest, type: " + type + ",
intent: " + i + ", data: " + data);
startService(i);
}

Service:

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
onHandleIntent(intent);
}
return START_STICKY;
}

protected void onHandleIntent(Intent intent) {
int type =
intent.getIntExtra(LocalApiService.INTENT_NAME_REQUEST_ID, -1);
prepareDataFromReceiver(type, intent.getExtras());
}



On 18 Кві, 19:38, Justin Anderson  wrote:
> > Sorry, it is problem with Service.
> > this one:
> >http://groups.google.com/group/android-developers/browse_thread/threa...
>
> Sorry, but a link to an identical problem posted by you doesn't prove this
> is a problem with the Service class..
>
> What does your code look like when you start the service?  And what does
> your service code look like where you try to get the Intent extras?
>
> Thanks,
> Justin Anderson
> MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
>
>
>
>
>
>
> On Wed, Apr 18, 2012 at 9:49 AM, viktor  wrote:
> > Sorry, it is problem with Service.
>
> > this one:
> >http://groups.google.com/group/android-developers/browse_thread/threa...
>
> > On 18 Кві, 18:14, Justin Anderson  wrote:
> > > What action are you receiving?  Is it your own custom action or one
> > defined
> > > by Android?  If it is a custom action then you would need to figure out
> > why
> > > you are sending the broadcast without extras.
>
> > > If it is defined by Android, then it may be some other application that
> > > sends the broadcast, in which case you could probably ignore it if there
> > > are no extras.
>
> > > Thanks,
> > > Justin Anderson
> > > MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
> > > On Wed, Apr 18, 2012 at 3:00 AM, viktor 
> > wrote:
> > > > Hi,
>
> > > > I had a simple app that has Service and Application.
>
> > > > Service sends broadcasts by Action with extras.
>
> > > > Application receive this broadcast and handle some action by key that
> > > > is in extras.
>
> > > > Sometime application receive empty extras, so if I get
> > > > Intent.getExtras(), the Bundle will be empty;
>
> > > > Any workarounds?
>
> > > > --
> > > > 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
>
> > --
> > 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

-- 
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: Broadcast receiver receive empty extras

2012-04-18 Thread viktor
Sorry, it is problem with Service.

this one: 
http://groups.google.com/group/android-developers/browse_thread/thread/f5c1f6af2914cde6

On 18 Кві, 18:14, Justin Anderson  wrote:
> What action are you receiving?  Is it your own custom action or one defined
> by Android?  If it is a custom action then you would need to figure out why
> you are sending the broadcast without extras.
>
> If it is defined by Android, then it may be some other application that
> sends the broadcast, in which case you could probably ignore it if there
> are no extras.
>
> Thanks,
> Justin Anderson
> MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
>
>
>
>
>
>
> On Wed, Apr 18, 2012 at 3:00 AM, viktor  wrote:
> > Hi,
>
> > I had a simple app that has Service and Application.
>
> > Service sends broadcasts by Action with extras.
>
> > Application receive this broadcast and handle some action by key that
> > is in extras.
>
> > Sometime application receive empty extras, so if I get
> > Intent.getExtras(), the Bundle will be empty;
>
> > Any workarounds?
>
> > --
> > 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

-- 
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