Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startActivity 跳转疑问 #4

Closed
Wing-Li opened this issue May 23, 2016 · 1 comment
Closed

startActivity 跳转疑问 #4

Wing-Li opened this issue May 23, 2016 · 1 comment

Comments

@Wing-Li
Copy link

Wing-Li commented May 23, 2016

跳转Activity的跳转方式,是这样的。

AnimalActivity.startActivity(this);

public class AnimalActivity extends AppCompatActivity {
    public static void startActivity(Context context) {
        Intent intent = new Intent(context, AnimalActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       ......
    }
}

这种跳转方式跟普通的直接跳转有什么区别吗?

 Intent intent = new Intent(this, AnimalActivity.class);
 this.startActivity(intent);
@dinuscxj
Copy link
Owner

@Wing-Li 1. 参数较少时便于控制传递的参数,2. 代码简洁,适用于多处调用 3. 不容易出错 4. 可读性也更好。等等啦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants