Ciao a tutti !! i almost give up. my app uses a datepicker to set a date ,for each date i set an alarm. My boadcastreceiver class receives an intent too .
here my code :
public class AlarmReceiver extends BroadcastReceiver{
String dato;
public Context context;
@Override
public void onReceive(Context context, Intent intent) {
dato=intent.getStringExtra("nome");
//intent.putExtra("nome", dato);
Toast toast =Toast.makeText(context, "Oggi e' il compleanno di " + dato , Toast.LENGTH_SHORT);
toast.show();
Intent i = new Intent();
i.setClassName("com.example.memopad", "com.example.memopad.CustomDialogActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle bundle = new Bundle();
bundle.putString("nome",dato);
i.putExtras(bundle);
context.startActivity(i);
}
}
when the alarm fires, CustomDialogActivity starts and a toast is launched i would like to use the string dato not only in the tosat but aven in the CustomDialogActivity
see the following code related to CustomDialogActivity :
p
ublic class CustomDialogActivity extends FragmentActivity {
TextView TextViewDialog ;
ImageView ImageViewCumple;
Button ButtonRitorna;
String dato1;
Intent intent;
Bundle bundle;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.customdialoglayout);
TextViewDialog=(TextView)findViewById(R.id.datacumple50);
ImageViewCumple = (ImageView)findViewById(R.id.imageView12);
ImageViewCumple = (ImageView)findViewById(R.id.imageView1);
ButtonRitorna =(Button)findViewById(R.id.tornaBirthDay);
ButtonRitorna.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent ( CustomDialogActivity.this,MenuActivity.class);
startActivity(i);
}
});
//dato1 = getIntent().getExtras().getString("nome");
//dato1=intent.getStringExtra("nome");
//TextViewDialog.setText(dato1);
bundle=intent.getExtras();
TextViewDialog.setText(" Oggi e' il compleanno di " + bundle);
}
Could you give me any hints?
Please !!!
While setting the text to TextViewDialog, use the following to get the text that was passed in the bundle. getIntent().getStringExtra("nome") I was able to print it in the toast as well as in the activity.