Android: Start Activity and pass parameters

The following example opens another activity / intent:

Intent intent = new Intent(getApplicationContext(), TargetIntent.class);
//add parameters
Bundle b = new Bundle();
b.putString("file", "myfile.pdf");
intent.putExtras(b);
startActivity(intent);
finish();

In the target intent, you can access the parameters like that:

Bundle b = getIntent().getExtras();
fileName = b.getString("file");

Werbung



comments powered by Disqus

Copyright Dunkel & Iwer GbR | Datenschutzerklärung | Impressum