activity高手进,关于flag的使用
先贴我要通过service启动的activity的manifest里面的配置参数,这个activity是程序的启动函数,也就是入口函数
<activity android:name=".TestActivity" android:label="@string/app_name" android:screenOrientation="landscape"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
<service android:name=".StartService" > <intent-filter> <action android:name="com.astrob.START_SERVICELINGHUA" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </service>
Intent it = new Intent(getBaseContext() , TestActivity.class); it.putExtra("Data", extras.getString("Data")); it.setAction(Intent.ACTION_MAIN); it.addCategory(Intent.CATEGORY_LAUNCHER); it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); it.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT ); it.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startActivity(it);