android intent scheme,android Scheme使用 打开指定的Activity
1.在配置文件AndroidMenifest.xml文件中增加下配置
注:上配置添加在需要使用Scheme控制啟動(dòng)的Activity下,例如:
android:name="com.example.pushtest.MainActivity"
android:label="@string/app_name" >
2.在需要啟動(dòng)該Activity的地方傳入U(xiǎn)ri值,如下
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
//如非特別需求,只需保證"test"與配置中的Scheme值相同即可,"://"后面可以任意
intent.setData(Uri.parse("test"+"://112345678"));
startActivity(intent);
3.在需要啟動(dòng)的Activity中,如需要獲取scheme及Uri的全路徑,可以使用如下方法:
Intent intent = getIntent();
String scheme = intent.getScheme();//獲取Scheme全名稱
String uriPath = intent.getDataString();//獲取Uri的全路徑
例如,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
String scheme = getIntent().getScheme();
String uriPath = getIntent().getDataString();
System.out.println("scheme::-->"+scheme+",uriPath:::"+uriPath);
}
總結(jié)
以上是生活随笔為你收集整理的android intent scheme,android Scheme使用 打开指定的Activity的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 小米的新logo与戴森的吹风机
- 下一篇: mysql冗余_如何合理使用数据库冗余字