Search code examples
androidandroid-intentandroid-pendingintent

Replace char inside Intent data


How can I replace (setting it permanently) a single char inside the data of an Intent?

The content of the Intent is in the form of DATA:VALUE.

    String test = getIntent().getData().toString();
    test = test.replaceFirst("a", "b");
    getIntent().setData(???); // how can I do this?

Solution

  • If I'm understanding you correctly you want to do this?

    String test = getIntent().getData().toString();
    test = test.replaceFirst("a", "b");
    getIntent().setData(Uri.parse(test));