android强制停止,android – ‘强制停止’在哪个生命周期中留下一个活动?

假设我的应用程序启动并运行.然后我去我的设备主屏幕.导航到设置>>应用程序>>管理应用程序,选择我的应用程序,然后按强制停止.

下次打开应用程序时会调用哪个Activity方法?在我因为没有检查自己而受到攻击之前,我在onCreate,onStart和onResume方法中有很多Log语句,但实际上在重新打开应用程序时,它们都没有显示在LogCat中.

如果您知道Force停止放置我的应用程序的状态的答案但是缺少的Log语句没有意义,请分享.我想除了我失去Force停止放置我的程序的地方之外可能会有一个不同的问题.

Android Activity LifeCycle:

的onCreate()

public void onCreate(Bundle savedInstanceState) {

Log.i( TAG,"Whats going onnnn0" );

// This calls all inherited methods,as this is a subclass of Activity.

super.onCreate(savedInstanceState);

if(D) Log.e(TAG,"+++ ON CREATE +++");

Log.i( TAG,"Whats going onnnn" );

// Set the view the main.xml

setContentView(R.layout.main);

RelayAPIModel.bluetoothConnected = false;

// Initialize the connection.

setupConnection();

Log.i( TAG,"Whats going onnnn2" );

// Check how if bluetooth is enabled on this device.

mService.checkBluetoothState();

// Initialize stuff from PilotMain() method

initMain();

Log.i( TAG,"Whats going onnnn3" );

// Add listeners to all of the buttons described in main.xml

buildButtons();

Log.i( "HERE","HERE" );

// If the adapter is null,then Bluetooth is not supported

if (mService.getAdapter() == null) {

Toast.makeText(this,R.string.toast_bt_not_avail,Toast.LENGTH_LONG).show();

finish();

return;

}

savedStuff = (SerializableObjects)LocalObjects.readObjectFromFile( getApplicationContext(),"LastDevice.txt" );

if( savedStuff != null ) {

hasLastDevice = true;

Log.i( "HAS","LAST DEVICE" );

Log.i( "HAS",savedStuff.getName() );

} else {

hasLastDevice = false;

Log.i( "HAS NO","LAST DEVICE" );

}

pairedDeviceList = new ArrayList();

pairedDevices = mService.getAdapter().getBondedDevices();

for( BluetoothDevice device: pairedDevices ) {

pairedDeviceList.add( device );

}

if( hasLastDevice ) {

for( int i = 0; i < pairedDeviceList.size(); i++ ) {

Log.i( "1 HERE HERE",pairedDeviceList.get( i ).getName() );

Log.i( "1 HEUH?I@JD",savedStuff.getName() );

if( pairedDeviceList.get( i ).getName().equals( savedStuff.getRealName() ) ) {

// THIS IS THE DEVICE WE NEED

prevIoUsDevice = pairedDeviceList.get( i );

i = pairedDeviceList.size();

}

}

}

}

在onStart()

public void onStart() {

super.onStart();

if(D) Log.e(TAG,"++ ON START ++");

savedStuff = (SerializableObjects)LocalObjects.readObjectFromFile( getApplicationContext(),"LAST DEVICE" );

}

pairedDeviceList = new ArrayList();

pairedDevices = mService.getAdapter().getBondedDevices();

for( BluetoothDevice device: pairedDevices ) {

pairedDeviceList.add( device );

}

if( hasLastDevice ) {

for( int i = 0; i < pairedDeviceList.size(); i++ ) {

Log.i( "2 HERE HERE",pairedDeviceList.get( i ).getName() );

Log.i( "2 HEUH?I@JD",savedStuff.getName() );

if( pairedDeviceList.get( i ).getName().equals( savedStuff.getRealName() ) ) {

// THIS IS THE DEVICE WE NEED

prevIoUsDevice = pairedDeviceList.get( i );

i = pairedDeviceList.size();

}

}

}

// If BT is not on,request that it be enabled.

// setupChat() will then be called during onActivityResult

if (!mService.getAdapter().isEnabled()) {

Log.i( TAG,"first !isEnabled " );

Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);

startActivityForResult(enableIntent,REQUEST_ENABLE_BT);

Log.i( TAG,"second !isEnabled" );

// Otherwise,setup the connection

} else {

if (mService == null) {

Log.i( TAG,"setupConnection BEFORE" );

setupConnection();

Log.i( TAG,"setupConnection AFTER" );

}

}

}

的onResume()

public synchronized void onResume() {

Log.i( "RESUME","HERE" );

super.onResume();

if(D) Log.e(TAG,"+ ON RESUME +");

Log.i( "RESUME","AFTER HERE" );

// Performing this check in onResume() covers the case in which BT was

// not enabled during onStart(),so we were paused to enable it...

// onResume() will be called when ACTION_REQUEST_ENABLE activity returns.

if (mService != null) {

// Only if the state is STATE_NONE,do we know that we haven't started already

if (mService.getState() == BluetoothService.STATE_NONE) {

// Start the Bluetooth chat services

mService.start();

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值