How to get data from other activity in android?

后端 未结 5 1106
-上瘾入骨i
-上瘾入骨i 2020-12-31 19:47

I have two activities such as Activity A and B and I\'m trying to pass two different strings from A to B using Bundle and startActivity(inten

5条回答
  •  隐瞒了意图╮
    2020-12-31 20:33

    I know I am 9 days late on this answer, but this is a good example of why I create a constants class. With a constants class, it doesnt matter if it is misspelled ("video" -> "vidoe") because it will be 'misspelled' in both places as you are referencing it through a well known location.

    Constants.java

    public static String WELL_KNOWN_STRING "org.example.stackoverflow.4792829";
    

    Activity1.java

    bundle.putString(Constants.WELL_KNOWN_STRING, filedetails);
    

    Activity2.java

    filedetails = extras.getString(Constants.WELL_KNOWN_STRING);        
    

提交回复
热议问题