2017년 5월 23일 화요일

back button is clicked, then can we put apk into background as "home" button?


I have a question about the action of "back" button clicked. I knew there is a way to handler BackPressed in screen, but it only provided the options of yes/no/cancel, actually instead of "no" or "cancel", I would like to put the app running in background as "home" button clicked. 
do you have any suggestion?

--
Use Android Studio.    App Inventor apps cannot run as a Service.  That means they cannot run in the background.  Also AI can use the BackPressed soft key but cannot use the Home soft key.

-- 
Actually I did see your reply regarding this topics, basically AI2 does not support it. 

And the reason I am still asking this question is because it seems to be working in some extent. For my APK, I started BLE connections, and I can send commands to BLE server to control the LED light for example, if I clicked "home" button or "power" button, the application is actually running in background for my understanding, then I selected this app back by collapse application window, I can see BLE connection is still here (I use timer to count it) and I still can control the remote by sending data via BLE connection. 

 However, it will NOT work when I click "back" button, That is why I was keeping asking about it. Is there any way to put app as clicking "home" button. 

-- 
You did NOT read this part  ' AI can use the BackPressed soft key but cannot use the Home soft key.'    AI cannot use the Home soft key but Android Studio can.

-- 
I understood your point. I was not looking for AI to use Home Soft Key, but my question is that when "backPressed", can AI do similar thing as "home" key pressed? since right now as I mentioned, there are three options "yes/no/cancel", surely, I did not want to quit the applicaiton, but just want it running as "home" key pressed. 

not sure if we can do it

-- 
You might be using the HOME button as a start extra task button,
if your Android settings don't destroy other tasks.

This is the equivalent of alt-tabbing in Windows.

I don't believe the first app runs, it just
is suspended.

-- 
you might want to try the MoveTaskToBack method from the simple notification extension

-- 

댓글 없음:

댓글 쓰기