Re: [android-developers] Start up application before sending intent

2016-01-19 Thread Justin Anderson
Glad you were able to get it worked out.

On Tue, Jan 19, 2016, 8:32 PM NuffsaidM8  wrote:

> As soon as I last posted I figured out what you meant and fixed the issue.
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to android-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-developers/de001d17-91d5-411d-b5bd-5f9b50027285%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CAOq06s__KmLZeLU7kNtYSinnxQA5bqU1Zc8Dzf9HmwjVFSdgkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Start up application before sending intent

2016-01-19 Thread NuffsaidM8
As soon as I last posted I figured out what you meant and fixed the issue. 
Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/de001d17-91d5-411d-b5bd-5f9b50027285%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Start up application before sending intent

2016-01-19 Thread NuffsaidM8
I retract my former statement about not understanding the passing data. I 
have found a solution. Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/288c10ae-dbf5-449b-a4e4-7bb34997090f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Start up application before sending intent

2016-01-19 Thread Justin Anderson
No, not quite...

The boot up of the phone is a special case scenario.  I'm saying that in
that scenario you can't rely on the broadcast system, so you need to come
up with another code path to manually get your activity's receiver code
executed.

I would take the code that is executed in your receiver and move it to a
new method in your activity class. Make the receiver call that method. Then
when your intent with special data comes in (it can be as simple as a
boolean value), you can call that same method and get the same result by
bypassing the broadcast mechanism.

I can explain in more detail later if that doesn't make sense (I'm on my
phone and helping my son with his homework right now), but hopefully that
gets you on the right path.

On Tue, Jan 19, 2016, 8:13 PM NuffsaidM8  wrote:

> I apologize for not taking the time to work out my issues all myself. I'm
> a little out of my league here and am on a tight schedule. I am still
> slightly confused about a few things, such as:
>
> Why do I need to pass data through to the activity? All I want to do right
> now is start it up so that when I broadcast an intent with a filter
> recognized by the other receiver, it executes the code in the receiver in
> the activity class. I think you are insinuating that I could check for the
> data and once I can read it I can send the intent. Is this correct?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to android-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-developers/6eafbab4-64bd-4358-91b4-f9b132741f9e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CAOq06s_XQ3Jiym0AoQGw_mDoAGKcPLbg7A81p56XqMMFBn%2BL6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Start up application before sending intent

2016-01-19 Thread NuffsaidM8
In addition, your theory about the activity being created too late is 
correct. I set a log statement in the onCreate method of the activity and 
this message was displayed to me. The message from the receiver in that 
class though was not displayed. The creation message was displayed after 
the message I put after I send the intent with the filter.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/6b449fe0-16a7-40f3-9fda-3603d0b7e801%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Start up application before sending intent

2016-01-19 Thread NuffsaidM8
I apologize for not taking the time to work out my issues all myself. I'm a 
little out of my league here and am on a tight schedule. I am still 
slightly confused about a few things, such as:

Why do I need to pass data through to the activity? All I want to do right 
now is start it up so that when I broadcast an intent with a filter 
recognized by the other receiver, it executes the code in the receiver in 
the activity class. I think you are insinuating that I could check for the 
data and once I can read it I can send the intent. Is this correct?

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/6eafbab4-64bd-4358-91b4-f9b132741f9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Start up application before sending intent

2016-01-19 Thread Justin Anderson
My apologies... looking at your code again, I was a bit mistaken... you are
using an explicit intent to start your activity.  My guess is that the
broadcast is getting sent before your activity has registered itself.

If that is indeed the case, I would suggest passing extra data through the
intent used to start the activity.  When your activity starts up, you can
look for this data, and if present, you know you are starting it from your
broadcast receiver and you need to reset the alarm (I assume you are doing
something like that based on the code).

I still think it would be good to read up on this though:
http://developer.android.com/guide/components/intents-filters.html

Sorry for the confusion... that's what I get for scanning the code too
quickly. I missed your startActivity() call in the middle of the code
snippet.

Hope that helps,
Justin

On Tue, Jan 19, 2016 at 4:21 PM Justin Anderson 
wrote:

> If you send a broadcast, and your activity isn't currently running, then
> your Broadcast receiver isn't registered with the OS. How could it be? Your
> activity hasn't run the code to register itself.  And, furthermore, if
> you've done it correctly, when your activity goes away, it should
> unregister itself or you will run into problems.
>
> I think you are confusing receivers with intent-filters. I would read
> through this before continuing:
> http://developer.android.com/guide/components/intents-filters.html
>
> I think what you are TRYING to do is the equivalent of using an intent
> filter to implicitly start your activity.  But that is likely overkill.
> When you are trying to launch an activity that is part of your own
> application, 99% of the time you will want to use an explicit intent to
> start the activity.
>
> In both cases, you will want to use the context.startActivity() method...
> The difference between implicit and explicit intents is in how you
> construct the Intent object.
>
> On Tue, Jan 19, 2016 at 4:02 PM NuffsaidM8  wrote:
>
>> I did the receiver with only code, that's correct. What do you mean that
>> I need to start the activity? I thought that was what I was doing.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Android Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to android-developers+unsubscr...@googlegroups.com.
>> To post to this group, send email to android-developers@googlegroups.com.
>> Visit this group at https://groups.google.com/group/android-developers.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/android-developers/dc32640d-926f-4033-9198-5b94e6f4298d%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CAOq06s_-sehxEY26U7U1XNkQmpHqR8upb%3D0jkMR3qsXAgFyk2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Start up application before sending intent

2016-01-19 Thread Justin Anderson
If you send a broadcast, and your activity isn't currently running, then
your Broadcast receiver isn't registered with the OS. How could it be? Your
activity hasn't run the code to register itself.  And, furthermore, if
you've done it correctly, when your activity goes away, it should
unregister itself or you will run into problems.

I think you are confusing receivers with intent-filters. I would read
through this before continuing:
http://developer.android.com/guide/components/intents-filters.html

I think what you are TRYING to do is the equivalent of using an intent
filter to implicitly start your activity.  But that is likely overkill.
When you are trying to launch an activity that is part of your own
application, 99% of the time you will want to use an explicit intent to
start the activity.

In both cases, you will want to use the context.startActivity() method...
The difference between implicit and explicit intents is in how you
construct the Intent object.

On Tue, Jan 19, 2016 at 4:02 PM NuffsaidM8  wrote:

> I did the receiver with only code, that's correct. What do you mean that I
> need to start the activity? I thought that was what I was doing.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to android-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-developers/dc32640d-926f-4033-9198-5b94e6f4298d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CAOq06s9nQ0xioMHhowziL9D6RnL-XtFwf%3D554o41o3kvTz%2BB9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Start up application before sending intent

2016-01-19 Thread NuffsaidM8
I did the receiver with only code, that's correct. What do you mean that I 
need to start the activity? I thought that was what I was doing.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/dc32640d-926f-4033-9198-5b94e6f4298d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Start up application before sending intent

2016-01-19 Thread Justin Anderson
>From what you've described, I suspect you are doing your receiver only in
code, which will not allow you to do what you want... This kind of receiver
is only active while your activity is active. Since your activity is not
active, neither is your receiver.

Why not just start your activity explicitly?

On Tue, Jan 19, 2016 at 3:34 PM NuffsaidM8  wrote:

> I have a broadcast receiver that is detecting a boot up of the phone. This
> part works fine. What I want to do is send a notification to a broadcast
> receiver in the Main Activity of the app, which is registered in the
> onCreate method as having an intent filter of "RESET_ALARM". This is what
> doesn't seem to be working. I tried starting the application with this
> (found it on stackkoverflow):
>
> Intent i = new Intent(context, MainActivity.class);
> i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> context.startActivity(i);
> Intent intent1 = new Intent("RESET_ALARM");
> context.sendBroadcast(intent1);
>
> but this does not seem to be working. I know the code is running, but a
> log statement in the receiver in the MainActivity.class file is not logging
> to the logcat. What am I doing wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to android-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-developers/948117f7-0e11-41a0-9745-f16e19099d17%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CAOq06s-6eU4js-JwqX0Otb3Og0%2Bg5JAWMkO%2BgGxXNpyYqmwCng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Start up application before sending intent

2016-01-19 Thread NuffsaidM8
I have a broadcast receiver that is detecting a boot up of the phone. This 
part works fine. What I want to do is send a notification to a broadcast 
receiver in the Main Activity of the app, which is registered in the 
onCreate method as having an intent filter of "RESET_ALARM". This is what 
doesn't seem to be working. I tried starting the application with this 
(found it on stackkoverflow):

Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Intent intent1 = new Intent("RESET_ALARM");
context.sendBroadcast(intent1);

but this does not seem to be working. I know the code is running, but a log 
statement in the receiver in the MainActivity.class file is not logging to 
the logcat. What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/948117f7-0e11-41a0-9745-f16e19099d17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.