切换活动而不使用Intent

Jui*_*iCe 3 singleton android android-intent

我正在研究一个项目,让我的活动通过Intents互相传递信息.但是,我最近决定使用swithc并使用Singleton方法并使用Application类来保存我的所有数据.

我现在有点困惑:如何在没有意图的情况下开始我的活动?这是我切换之前的一个电话......

    public boolean onOptionsItemSelected( MenuItem item ) {
    switch( item.getItemId() ) {
    case R.id.connect:
        startActivityForResult( new Intent( this, DeviceList.class ), REQUEST_CONNECT_DEVICE  );
        return true;
Run Code Online (Sandbox Code Playgroud)

如果不使用意图,我会将其更改为启动DeviceList类?

kab*_*uko 9

你没有.使用意图开始您的活动.这就是Android的设计方式.

  • 除了链接到@Squonk的文档之外,您可能还想阅读[应用程序基础知识文档](http://developer.android.com/guide/topics/fundamentals.html),尤其是[激活组件]部分( http://developer.android.com/guide/topics/fundamentals.html#ActivatingComponents). (2认同)