自定义URL用scheme唤起Activity

1.在AndroidManifest.xml中定义shceme:

android:name="..SchemeActivity" android:screenOrientation="portrait">

2.解析:

public class SchemeActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

initIntent();

}

private void initIntent() {

Uri uri = Uri.parse(getIntent().getDataString());

//获取param

String id = uri.getQueryParameter("id");

String typeStr = uri.getQueryParameter("type");

Intent intent ;

switch (typeStr) {

case "0":

//处理

break;

default:

break;

}

startActivity(intent);

finish();

}

}

 

 

 

你可能感兴趣的:(android)