Re: [android-developers] Custom Listener is Null in BroadcastReceiver

2017-01-06 Thread jacqulinewoody via Android Developers


On Sat, 1/7/17, king.joel via Android Developers 
<android-developers@googlegroups.com> wrote:

 Subject: Re: [android-developers] Custom Listener is Null in BroadcastReceiver
 To: android-developers@googlegroups.com
 Date: Saturday, January 7, 2017, 7:12 AM
 
 
 
 On Fri, 1/6/17, Navid Arfaie <navid.arf...@gmail.com>
 wrote:
 
  Subject: Re: [android-developers] Custom Listener is Null
 in BroadcastReceiver
  To: android-developers@googlegroups.com
  Date: Friday, January 6, 2017, 9:42 PM
  
  Thanks A lot :)
  
  
  
  -- 
  
  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/CA%2BdJ5aHOgqetCDO_vJySWhVM6tv%2B0UrcONqcAw2ChcgSi6rUHw%40mail.gmail.com.
  
  For more options, visit
 https://groups.google.com/d/optout.
  uvernul revolutionar din tara Romaneasca a actionat 
 in acelasi timp  i recunoasterea sa de catre puterile
 europene. Pentru aceasta au ?urat o bogata activitate
 diplomatica Ion Ghica la Constantinopol  ndru G.
 Golescu la Paris  Dimitrie Bratianu la Pesta  Ion
 Maiorescu la furt. Desi ascuns  din considerente
 tactice  obiectivul unitatii nationale a iereu prezent
 in toate actiunile revolutionare. La 12 iunie 1848  in
 gazeta  ui roman  dm Bucuresti  aparea
 manifestul intitulat Catre fratii nostri din
 >va   in care era subliniata ideea
 deplinei unitati nationale. Peste numai o nana  August
 Treboniu Laurian ii propunea lui Nicolae Balcescu
 izarea  la Bucuresti  a unui Congres al tuturor
 romanilor. Activitatea diplomatica desfasurata de
 revolutionarii romani in capitalele ene urmarea sa evite o
 interventie militara  a Rusiei si a Imperiului an 
 care se profila. La 31 iulie 1848  printr-o nota
 diplomatica. Rusia a imnat violent revolutia romana si a
 acuzat pe romani ca doresc sa se ca intr-un singur stat.
 Succesiunea evenimentelor din Transilvania si tara neasca a
 insufletit  din nou  miscarea romaneasca din
 Moldova. In august 1848 a fost redactat  de catre
 Mihail Kogalniceanp  la Cernauti  amul  atat
 de semnificativ intitulat  Dorinte e partidei nationale
 in Moldova  derile sale au fost dezvoltate 
 ulterior  in Proiectul de constitutie pentru wa . Erau
 cuprinse  aici  elemente de baza ale viitorului
 stat roman modern etatea intrunirilor si a cuvantului 
 a persoanei  egalitatea in fata legit 
 nsabilitatea ministeriala  desfiintarea privilegiilor.
 Demn de remarcat este irea Moldovei cu tara Romaneasca era
 considerata cheta boltii fara de i-ar prabusi intreg
 edificiul national .Fruntasi ai revolutiei romane de la
 1848  din tara Romaneasca
 
 -- 
 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/555787947.69405.1483765935674%40mail.yahoo.com.
 For more options, visit
 https://groups.google.com/d/optout.neau doar solutii morale   concretizate 
apoi in propunerea mentinerii pe

-- 
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/2049949830.114597.1483770437070%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Custom Listener is Null in BroadcastReceiver

2017-01-06 Thread king.joel via Android Developers


On Fri, 1/6/17, Navid Arfaie <navid.arf...@gmail.com> wrote:

 Subject: Re: [android-developers] Custom Listener is Null in BroadcastReceiver
 To: android-developers@googlegroups.com
 Date: Friday, January 6, 2017, 9:42 PM
 
 Thanks A lot :)
 
 
 
 -- 
 
 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/CA%2BdJ5aHOgqetCDO_vJySWhVM6tv%2B0UrcONqcAw2ChcgSi6rUHw%40mail.gmail.com.
 
 For more options, visit https://groups.google.com/d/optout.
 uvernul revolutionar din tara Romaneasca a actionat  in acelasi timp  i 
recunoasterea sa de catre puterile europene. Pentru aceasta au ?urat o bogata 
activitate diplomatica Ion Ghica la Constantinopol  ndru G. Golescu la Paris  
Dimitrie Bratianu la Pesta  Ion Maiorescu la furt. Desi ascuns  din 
considerente tactice  obiectivul unitatii nationale a iereu prezent in toate 
actiunile revolutionare. La 12 iunie 1848  in gazeta  ui roman  dm Bucuresti  
aparea manifestul intitulat Catre fratii nostri din >va   in care era 
subliniata ideea deplinei unitati nationale. Peste numai o nana  August 
Treboniu Laurian ii propunea lui Nicolae Balcescu izarea  la Bucuresti  a unui 
Congres al tuturor romanilor. Activitatea diplomatica desfasurata de 
revolutionarii romani in capitalele ene urmarea sa evite o interventie militara 
 a Rusiei si a Imperiului an  care se profila. La 31 iulie 1848  printr-o nota 
diplomatica. Rusia a imnat violent revolutia romana si a acuzat pe romani ca 
doresc sa se ca intr-un singur stat. Succesiunea evenimentelor din Transilvania 
si tara neasca a insufletit  din nou  miscarea romaneasca din Moldova. In 
august 1848 a fost redactat  de catre Mihail Kogalniceanp  la Cernauti  amul  
atat de semnificativ intitulat  Dorinte e partidei nationale in Moldova  derile 
sale au fost dezvoltate  ulterior  in Proiectul de constitutie pentru wa . Erau 
cuprinse  aici  elemente de baza ale viitorului stat roman modern etatea 
intrunirilor si a cuvantului  a persoanei  egalitatea in fata legit  
nsabilitatea ministeriala  desfiintarea privilegiilor. Demn de remarcat este 
irea Moldovei cu tara Romaneasca era considerata cheta boltii fara de i-ar 
prabusi intreg edificiul national .Fruntasi ai revolutiei romane de la 1848  
din tara Romaneasca

-- 
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/555787947.69405.1483765935674%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Custom Listener is Null in BroadcastReceiver

2017-01-06 Thread Navid Arfaie
Thanks A lot :)

-- 
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/CA%2BdJ5aHOgqetCDO_vJySWhVM6tv%2B0UrcONqcAw2ChcgSi6rUHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Custom Listener is Null in BroadcastReceiver

2017-01-05 Thread Marina Cuello
Hi!
Are you declaring your receiver on the manifest or somewhere else on the
code? I'm copying this from an example I Googled, so it might not be
exactly what you need, but here are two ways to declare the receiver:

On android_manifest.xml






On your code
// Register a broadcast receiver
IntentFilter intentFilter = new
IntentFilter("android.intent.action.DATA_SMS_RECEIVED");
intentFilter.setPriority(10);
intentFilter.addDataScheme("sms");
intentFilter.addDataAuthority("*", "6734");
registerReceiver(incomingSms, intentFilter);

Marina


On Wed, Dec 28, 2016 at 3:24 AM, Navid Arfaie 
wrote:

> I Create a BroadcastReciver and want to call a method when SMS Recived!
> this code work correctly in other classes but not fire in BroadcastReciver.
>
>
> *My BroadcastReciver.java:*
>
>
> public class IncomingSms extends BroadcastReceiver {
> String smsBody;
>
> private SmsListener smsListener;
>
> public interface SmsListener {
> void PassActivate();
> };
>
> public void setSmsListener(SmsListener listener) {
> smsListener = listener;
> }
>
> public static final String SMS_BUNDLE = "pdus";
> @Override
> public void onReceive(Context context, Intent intent) {
>
> String address = "";
> Bundle intentExtras = intent.getExtras();
> if (intentExtras != null) {
> Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE);
> String smsMessageStr = "";
> for (int i = 0; i < sms.length; ++i) {
> SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);
>
> smsBody = smsMessage.getMessageBody().toString();
> address = smsMessage.getOriginatingAddress();
> }
>
> String strOrig = smsBody;
>
> try {
> if (strOrig.contains("_Activated_"))  {
> if(smsListener!=null){
> smsListener.PassActivate();
> }
>
> } else {
> Toast.makeText(context, "Ops", Toast.LENGTH_LONG).show();
> }
>
> } catch (Exception e) {
> Toast.makeText(context, "Ops", Toast.LENGTH_LONG).show();
> }
>
> }
>
> }
>
>
> When SMS recive , I chek smsListener.But it's always null!
>
>
> *and My Activity:*
>
>
> import arfaie.navid.mei.IncomingSms.SmsListener;
>
> public class Activate extends Activity {
>
> private IncomingSms incomingSms;
>
> @Override
> protected void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.activity_activate);
>
> incomingSms = new IncomingSms();
> incomingSms.setSmsListener(smsListener);
>
> }
>
> SmsListener smsListener = new SmsListener() {
> @Override
> public void PassActivate() {
> Toast.makeText(getBaseContext(), "It Works", 
> Toast.LENGTH_SHORT).show();
> }
> };
>
>
>
> --
> 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/0fa831c4-5c2e-4151-8dbf-
> afe51f73b880%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/CACaNmX0mD%3DGEKGY7_8dbtOXtkhTqAqZa95JYmuB%3DYiOwcZ_88g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Custom Listener is Null in BroadcastReceiver

2016-12-27 Thread Navid Arfaie


I Create a BroadcastReciver and want to call a method when SMS Recived! 
this code work correctly in other classes but not fire in BroadcastReciver.


*My BroadcastReciver.java:*


public class IncomingSms extends BroadcastReceiver {
String smsBody;

private SmsListener smsListener;

public interface SmsListener {
void PassActivate();
};

public void setSmsListener(SmsListener listener) {
smsListener = listener;
}

public static final String SMS_BUNDLE = "pdus";
@Override
public void onReceive(Context context, Intent intent) {

String address = "";
Bundle intentExtras = intent.getExtras();
if (intentExtras != null) {
Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE);
String smsMessageStr = "";
for (int i = 0; i < sms.length; ++i) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);

smsBody = smsMessage.getMessageBody().toString();
address = smsMessage.getOriginatingAddress();
}

String strOrig = smsBody;

try {
if (strOrig.contains("_Activated_"))  {
if(smsListener!=null){
smsListener.PassActivate();
}

} else {
Toast.makeText(context, "Ops", Toast.LENGTH_LONG).show();
}

} catch (Exception e) {
Toast.makeText(context, "Ops", Toast.LENGTH_LONG).show();
}

}

}


When SMS recive , I chek smsListener.But it's always null!


*and My Activity:*


import arfaie.navid.mei.IncomingSms.SmsListener;

public class Activate extends Activity {

private IncomingSms incomingSms;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activate);

incomingSms = new IncomingSms();
incomingSms.setSmsListener(smsListener);

}

SmsListener smsListener = new SmsListener() {
@Override
public void PassActivate() {
Toast.makeText(getBaseContext(), "It Works", Toast.LENGTH_SHORT).show();
}
};



-- 
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/0fa831c4-5c2e-4151-8dbf-afe51f73b880%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.