How to implement my very own URI scheme on Android

后端 未结 5 763
借酒劲吻你
借酒劲吻你 2020-11-22 06:12

Say I want to define that an URI such as:

myapp://path/to/what/i/want?d=This%20is%20a%20test

must be handled by my own application, or serv

5条回答
  •  深忆病人
    2020-11-22 07:14

    Complementing the @DanielLew answer, to get the values of the parameteres you have to do this:

    URI example: myapp://path/to/what/i/want?keyOne=valueOne&keyTwo=valueTwo

    in your activity:

    Intent intent = getIntent();
    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
      Uri uri = intent.getData();
      String valueOne = uri.getQueryParameter("keyOne");
      String valueTwo = uri.getQueryParameter("keyTwo");
    }
    

提交回复
热议问题