我将Activity Theme设置为Theme.NoDisplay但是当它打开但按下后按钮Activity不关闭/销毁.它应该在背压下关闭/销毁.
public class MainActivity extends Activity { // Tag of the Activity private static String TAG = "MainActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); DatabaseManager.init(this); NFCIItem mNFCItem = new NFCIItem(); mNFCItem.setSerialNumber(1); DatabaseManager.getInstance().addWishList(mNFCItem); final List<NFCIItem> wishLists = DatabaseManager.getInstance().getAllNFCSerialNumber(); Log.v(TAG,wishLists.toString()); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main,menu); return true; } }
AndroidManifest.xml中
<activity android:name="com.example.appdemo.MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoDisplay" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>