mstfdz
mstfdz

Reputation: 2796

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

I am trying to find how to understand phone is in use ? I dont know is there a easy way to do that. I have some tasks to do in the following lines. For example how can i know user is making call or sending sms.

Actually there is three basic context that i want to know and theese are : Smartphone is not in use, Smartphone is not handled, Smartphone is not moving.

and these are the detailed task that 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)

Upvotes: 4

Views: 98

Answers (1)

Arjun Chaudhary
Arjun Chaudhary

Reputation: 2453

1.Use the accelerometer to detect if the phone user is moving.Hence u will know phone is moving or Not.

2.For incoming calls we need to use the TelephonyManager class and its method listen to register a listener that will receive call state, data connection, network, SIM, and other events related to telephony. We are interested only in the call state notifications. This requires android.permission.READ_PHONE_STATE permission.

3.state is the call state, it can be CALL_STATE_RINGING, CALL_STATE_OFFHOOK, or CALL_STATE_IDLE. Ringing is the state when someone is calling us, offhook is when there is active or on hold call, and idle is when nobody is calling us and there is no active call. We are interested in the ringing state.

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

It will guide u through the code.

Upvotes: 1

Related Questions