常见Android Start Activity用法汇总

//Calls another activity, by name, without passing data

Intent iExp = new Intent(this, ActivityToCall.class); //TODO  Replace 'ActivityToCall' with the class name of the activity being called

startActivity(iExp);

 

//Calls another activity, by action and category, without passing data
//refer to AndroidManifest.xml<intent-filter> when determining the action and category of the activity to call
Intent iImp = new Intent("actionName"); //TODO Replace 'actionName' as appropriate for your action (for example, Intent.ACTION_EDIT)
iImp.addCategory("categoryName"); //TODO Replace 'categoryName' as appropriate for your category (for example, Intent.CATEGORY_DEFAULT)
startActivity(iImp);	
 
//Calls another activity, identified by action and category, passing data URL and a MIME type
//The class calling the snippet code must implement the following method:
//protected void onActivityResult (int requestCode, int resultCode, Intent data) {}
Intent iImp = new Intent();
iImp.setAction("actionName"); //TODO Replace 'actionName' as appropriate for your action (for example, Intent.ACTION_EDIT)
iImp.addCategory("categoryName"); //TODO Replace 'categoryName' as appropriate for your category (for example, Intent.CATEGORY_DEFAULT)
//optional - set data and MIME type for the intent
iImp.setDataAndType(Uri.parse("http://com.example.project/folder"), "text/plain"); //TODO Change URL and MIME type as appropriate
startActivityForResult(iImp, 0); //TODO The second parameter (here, zero) is the request code to be used in onActivityResult(); change this parameter to an appropriate value for your activ
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值