How to understand that a user is interacting with a phone (Android)?

I'm trying to find how to understand that the phone is in use? I do not know if there is an easy way to do this. I have several tasks in the following lines. For example, how can I find out that the user is making a call or sending SMS.

In fact, there are three main contexts that I want to know, and they are: The smartphone is not used, the smartphone is not processed, the smartphone is not moving.

and this is the detailed task I want to know:

  1- User is interacting with the phone(also carrying)
    App Usage
    Call
    Sms
    Activities
     Detailed Context
       Smartphone is in use
       Smartphone is handled or not
       Moving(not at all,slightly, a lot)
       Location(hand, pocket,bag)
  2- User isn't carrying the phone
    Phone stationary
    Detailed Context
    Smartphone is not in use
    Smartphone is not handled
    Smartphone is not moving
    Location(not worn)
+4
source share
1 answer

1.Use the accelerometer to determine if the phone user is moving. You will know that the phone is moving or not.

2. TelephonyManager, , , , , SIM , . . android.permission.READ_PHONE_STATE.

3.state - , CALL_STATE_RINGING, CALL_STATE_OFFHOOK CALL_STATE_IDLE. - , - , - , - , . .

: http://www.codeproject.com/Articles/548416/Detecting-incoming-and-outgoing-phone-calls-on-And

u .

+1

Source: https://habr.com/ru/post/1531915/


All Articles