Already addressed here: http://stackoverflow.com/q/12333115/115145
On Sat, Sep 8, 2012 at 2:17 PM, Ehsan Sadeghi <[email protected]> wrote: > I create a broadcast receiver : > > package ir.smspeik.sms; > > > import android.content.BroadcastReceiver; > import android.content.Context; > import android.content.Intent; > import android.os.Bundle; > import android.telephony.SmsMessage; > > public class ReceiveSms extends BroadcastReceiver{ > @Override > public void onReceive(Context context, Intent intent) > { > //---get the SMS message passed in--- > //---get the SMS message passed in--- > Bundle bundle = intent.getExtras(); > SmsMessage[] msgs = null; > String str = ""; > if (bundle != null) > { > //---retrieve the SMS message received--- > Object[] pdus = (Object[]) bundle.get("pdus"); > msgs = new SmsMessage[pdus.length]; > for (int i=0; i<msgs.length; i++){ > msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]); > //str += "SMS from " + msgs[i].getOriginatingAddress(); > //str += " :"; > str += msgs[i].getMessageBody().toString(); > //str += "\n"; > } > > //---display the new SMS message--- > //Toast.makeText(context, str, Toast.LENGTH_SHORT).show(); > //---launch the MainActivity--- > //String[] sms = str.split("-"); > // if(sms[1] == "140") > //{ > Intent mainActivityIntent = new Intent(context, > ir.smspeik.sms.GetResponse.class); > mainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); > > context.startActivity(mainActivityIntent); > > //MyMenu mymen = new MyMenu(); > // mymen.invisibleMenuItem(R.id.menusms); > //---send a broadcast to update the SMS received in the activity--- > Intent broadcastIntent = new Intent(); > broadcastIntent.setAction("SMS_RECEIVED_ACTION"); > //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK" > broadcastIntent.putExtra("sms", str); > context.sendBroadcast(broadcastIntent); > //} > this.abortBroadcast(); > // this.clearAbortBroadcast(); > } > } > } > > and have a menu in my activities. I create a class extends activity and > create menu. My all activities extend that class. I want to hide some menu > buttons when broadcast receiver is called. How can I do that? > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 4.1 Available! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

