---
title: "Intent用法"
author: "zezhao"
date: "2010-11-02T11:39:11Z"
tags: []
categories: ["移动开发"]
slug: "intent"
draft: false
lastmod: "2010-11-02T11:39:11Z"
id: 800449
url: "https://zezhao.iteye.com/blog/800449"
---

**Intent用法实例**

**1.无参数Activity跳转**

```
Intent it = new Intent(动作页面, 跳转页面);
startActivity(it);   
```

 

**2.向下一个Activity传递数据（使用Bundle和Intent.putExtras）**

```
Intent it = new Intent(Activity.Main.this, Activity2.class);
Bundle bundle=new Bundle();
bundle.putString(key, value);	//key作为传递的参数
it.putExtras(bundle);         
startActivity(it);            
```

对于数据的获取可以采用：

```
Bundle bundle=getIntent().getExtras();
String name=bundle.getString(value);	//接收的值也是上面的key
```