第一种情况

Andorid中如果一个程序打开另一个程序的Main类的时候,可以直接使用以下的方法

                ComponentName componentName = new ComponentName(
                 "com.zhai.rdp.client", "com.zhai.rdp.Activity_Desktop");
                ‘intent.setComponent(componentName);

                intent.putExtra("FromSSL", true);
                intent.putExtra("host", host);

                intent.setAction("android.intent.action.MAIN");  //这句可要可不要
                try {
                    startActivity(intent);
                } catch (Exception e) {
                    Toast.makeText(
                            DesktopDisplayActivity.this,
                            "Do not find the application zhai Remote Destop Client ,Please install it . ",
                            Toast.LENGTH_LONG).show();
                }

第二种情况

但是如果想要打开一个非Main Activity 的时候必须要加的内容

                 ComponentName componentName = new ComponentName(
                "com.zhai.rdp.client", "com.zhai.rdp.Activity_Desktop");
                 ‘intent.setComponent(componentName);

                intent.putExtra("FromSSL", true);
                intent.putExtra("host", host);

               intent.setAction("com.view.desktop");
                try {
                    startActivity(intent);
                } catch (Exception e) {
                    Toast.makeText(
                            DesktopDisplayActivity.this,
                            "Do not find the application Adt Remote Destop Client ,Please install it . ",
                            Toast.LENGTH_LONG).show();
                }

 

<activity
            android:name="com.zhai.rdp.Activity_Desktop"
            android:configChanges="orientation|keyboard|keyboardHidden"
            android:label="@string/app_name"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:windowSoftInputMode="stateVisible|adjustResize" >
            <intent-filter>
                <action android:name="com.zhai.desktop" />
            </intent-filter>
        </activity>

注:一定要加上intent filter 节点,不然打开不了这个Activity