i want to pass some information from the received message when i receive it such as the content of the message or the source number of it, and i want to put that information in a button on when a certain condition is true not oncreate, am building messaging application so i want to store my received message in “inbox” how can i do that?
Ps. my onreceive method in a class extends broadcastReceiver and my other class extends activity
thanks in advance!
here is my first class where i extends broadcastreceiver
public class Re extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String address="";
String body="";
long time = 0;
if (bundle != null)
{
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
address= msgs[i].getOriginatingAddress();
body=msgs[i].getMessageBody().toString();
time=msgs[i].getTimestampMillis();
}
}
and here is my second class where i extends activity
public class ThirdView extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.third);
}
}
If you want to have access to your activity from Receiver’s onReceive – then you should define BroadcastReceiver as inner class of the Actvity and register it programmatically (in onStart method, and unregister in onStop);