I have a string value in one activity that has file path of audio as a TextView
and I want this to be sent to another Activity
. which to be played on android media player.
Asked
Active
Viewed 168 times
3 Answers
0
You can send any information to another activities using intents->
You can put String Extra --> myIntent.putStringExtra("MyKey","www.myurl.com");
You can put serializeable data class to intent.

Mr. Sanjay
- 34
- 2
0
You can pass like this
Intent i = new Intent(ActivityOne.this, ActivityTwo.class);
i.putExtra("username", "foobar");
i.putExtra("in_reply_to", "george");
i.putExtra("code", 400);
// brings up the second activity
startActivity(i);

Basi
- 3,009
- 23
- 28
0
While opening the second activity from first, you can create intent and pass the string with it -
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
intent.putExtra("path", "your_path_to_audio_file");
startActivity(intent);
and in the second activity, in order to get the string, you do the following -
String path = getIntent().getStringExtra("path");

BATMAN
- 425
- 4
- 13
-
thanks its working.. and how to add this string value on create media player to play audio from file path. – Raj Bedi Apr 26 '18 at 06:40