0

Im trying to get incomingcall number with qpython on android 4.4.3

Already try this:

import androidhelper
w=1
while (w == 1):
    droid = androidhelper.Android()
    droid.startTrackingPhoneState()
    phonest = droid.readPhoneState()
    number = phonest[2] # If i try to use ['incomingNumber'] not work
    if number != None:
       droid.makeToast('Call from '+number)

I Always get NullPointer Exception

I read this: python function call syntax ... result = foo() ['abc'] But is not working at all because: This is not working:

import android
droid = android.Android()

And when i try this:

outerDict = droid.readPhoneState()
innerDict = outerDict['result']
number = innerDict['incomingNumber']

Error because need to be integer or something like that.

Community
  • 1
  • 1
alien4u
  • 1
  • 2

2 Answers2

0

QPython didn't incude the READ_PHONE_STATE permission, please use the QPython3 instead.

River
  • 66
  • 2
0

I think I'm facing similar kind of behaviour, with just running test script that comes with QPython app (using QPython3). The output is:

Running test_phone_state... java.lang.NullPointerException PASS

Tried to catch the exception with python except block, but it just goes directly to finally clause, so I can't get traceback. I think that the "java.lang.NullPointerException" printout comes from lower java facade level, and the error traceback can't be accessed in the python layer.

However the testcode uses sl4a import instead of androidhelper. I'm not sure what's the difference there. The null pointer exception is printed out when startTrackingPhoneState is called. I'm wondering if this related to old Android version (using 4.4.2), or old Android Facade version, or maybe the documentation and test script how to use startTrackingPhoneState is old. The worst case scenario is that there's a bug somewhere on the Android Facade layer.

This is not exactly an answer to the question, but I don't have rights to write comments. So these are my observations on the subject.

MattiR
  • 1